Q. What will be the output of the following C code?

Code:
        #include <stdio.h>
        int main()
        {
            int a[5] = {1, 2, 3, 4, 5};
            int i;
            for (i = 0; i < 5; i++)
                if ((char)a[i] == '5')
                    printf("%d\n", a[i]);
                else
                    printf("FAIL\n");
        }
  • (A) The compiler will flag an error
  • (B) The program will compile and print the output 5
  • (C) The program will compile and print the ASCII value of 5
  • (D) The program will compile and print FAIL for 5 times
πŸ’¬ Discuss
βœ… Correct Answer: (D) The program will compile and print FAIL for 5 times

You must be Logged in to update hint/solution

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
259
Total Visits
πŸ“½οΈ
4 y ago
Published
πŸŽ–οΈ
Deepak Sahoo
Publisher
πŸ“ˆ
83%
Success Rate