C Programming - Input / Output - Discussion

Discussion Forum : Input / Output - Find Output of Program (Q.No. 10)
10.
What will be the output of the program ?
#include<stdio.h>

int main()
{
    printf("%%%%\n");
    return 0;
}
%%%%%
%%
No output
Error
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
36 comments Page 4 of 4.

Viswa said:   1 decade ago
Thank you neeranjan. Your explanation is correct for this output.

Ramesh said:   1 decade ago
Agree with the Niranjan but a small change. If want print %.

Dirctly printing occurred.

Vidhya said:   1 decade ago
I agree with Niranjan.

Josna said:   1 decade ago
printf("%%%\n");

This will also gives the output of %% . Why ?

Sumedh said:   1 decade ago
I think it uses the first % as formate string and remaining two are printed and used \n to move cursor to next line.

Ganesh said:   1 decade ago
My suggestion is, In C, we need a memory reference variable after the % symbol. In the above code, it considers % as memory reference variable and it prints. Try with %%%%%. It will print %%%. Its because, %% %% %.Split it into pair and then try it.


Post your comments here:

Your comments will be displayed after verification.