Answer to Question #53567 in C for rajashree g.s.

Question #53567
int main()
int x=10,y=20;
printf("\n %d %d",x,y);
return 0;

I want the output and explanation.
Expert's answer

Note: The program won’t compile if “#include” statement is not followed by included library <stdio.h>
First line of main function declares two integer variables x and y and assigns values 10 and 20 to them respectively.
The next line is condition branching. However, the expression after “if” and condition in braces is a single semicolon which is empty instruction that does nothing. Thus, no matter what is the result of comparing, nothing is executed.
The next line contains output statement using printf function. “printf” function outputs text in its first argument and next arguments in place of specificators which starts with percent ‘%’ symbol in text. ‘\n’ is an escape sequence for new line, and ‘%d’ is specificator of decimal integer. Therefore, what will be outputted is new line, space, integer, space, integer.
The first integer is x which equals 10, the second integer is y which equals 20.
Thus, the program outputs new line, space, 10, space, 20.

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!


No comments. Be the first!

Leave a comment

Ask Your question

New on Blog