D

Deepak Sahoo • 10.78K Points
Tutor II

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

No solution found for this question.
Add Solution and get +2 points.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.


Question analytics