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 2 of 4.

Pavankumar said:   8 years ago
Should we write printf ("\" " ") ;
Printf("""");

What will be display?
(1)

Chandrakumar said:   1 decade ago
Ya. Thank you niranjan I'm cleared from your explanation and I also for salesh for given a logic behind this.

Salesh said:   2 decades ago
As similarly if you want to print \n in C the syntax is

printf("\\n");

Same concept is here also.

Rajkumar said:   1 decade ago
After the % the C expects a format specifier so it assumes one % as format specifer and prints %% as output

Divya said:   8 years ago
@Ganesh.

You are right. In GCC, it is taking like that. Don't know about turbo C. Thank you, friends.

Amit agarwal said:   9 years ago
Also, we can't print " " using simple printf (" " " ") ;.

Should we write printf ("\" " ") ;?

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

Dirctly printing occurred.

Mangai said:   1 decade ago
Ya I accept Niranjan's answer.

Thank you Niranjan for giving the detailed ans.

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

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

Baadal said:   1 decade ago
Each % read the next single character hence it is printing only two %.


Post your comments here:

Your comments will be displayed after verification.