C programming good questions with answer

(q) What will be output of the following program ?
void main(){
int x=012,y;
clrscr();
y=++x- ~x+4?5:6;
printf("%#X %x",y,y);
getch();
}
Output: 0X5 5
Explanation:
012 is octal number because it is staring with number zero. %x, %X is used for to print the number in hexadecimal format. # indicates output should in the format: 0x number.
(q) What will be output of the following program?
void main(){
int x=0x12,y;
clrscr();
y=(x,1,10)+x,1,10;
printf("%#o, %o",y,y);
getch();
}
Output: 034 34
Explanation:
0x12 is hexadecimal number because it is staring with 0x. %o is used for to print the number in octal format.
# indicates output should in the format: 0 numbers.

No comments: