Question
Comment on the output of this C code?   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");   }
Answer: Option D
Was this answer helpful ?
The ASCII value of 5 is 53, the char type-casted integral value 5 is 5 only.
Output:
$ cc pgm1.c
$ a.out
FAILED
FAILED
FAILED
FAILED
FAILED
Was this answer helpful ?
More Questions on This Topic :
Question 1. What is the size of an int data type? ....
Question 5. What is short int in C programming? ....
Submit Solution