Sail E0 Webinar
Question


What is the output of the following program?


#include<stdio.h>
int main()
{
int c=08;
printf("%c",c);
return 0;
}
Options:
A .  8
B .  0
C .  Compile Error
D .  None of the above
Answer: Option C

Any number starting with 0 is treated as an octal value.


Here, 08 is an invalid octal value and hence the compiler throws the following error:


myprog.c:3:8: error: invalid digit "8" in octal constant




Was this answer helpful ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers