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;
}
Discussion:
36 comments Page 2 of 4.
Ponrasu said:
1 decade ago
why for printing %% in c?? wat reason?? tis is only c are c++
Rajkumar said:
1 decade ago
After the % the C expects a format specifier so it assumes one % as format specifer and prints %% as output
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.
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 ?
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.
Baadal said:
1 decade ago
Each % read the next single character hence it is printing only two %.
Sneha said:
1 decade ago
Yes I got it.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers