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.

Narayan said:   1 decade ago
I don't get anyone answer. Can anyone please explain about :

1. printf("%%%\n") (what will be o/p).
2. printf("%%\n") (what will be o/p).
3. printf("%\n") (what will be o/p).

Give ans respectively with proper explanation.

Bhavesh jain said:   1 decade ago
printf("%\n")

It will give output % . and to print % in c we have to add \n or \t or \r ..so it will terminate the % which starts finding for the d,s,c,f char to print something. so if we give \t ,\n then it will stop finding and simply print %.

K Jagannadham said:   1 decade ago
We can print % in C.

But another way to print % we need %% in C.

But to print %% we need %%% or %%%% in C.

And next to print %%% we need %%%%% or %%%%%% in C.
And so on.....

Sunil said:   10 years ago
C is sea. If you want to find it will in deep.

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

R.Monika said:   9 years ago
I want some more detail explanations! please help me friends.

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.

Prajwalita said:   6 years ago
Thanks all for the explanation.

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.

Niranjan said:   2 decades ago
Because we can't print % in C.

To print % we need %% in C for printing single %.

Hence to print %% we need %%%%.


Post your comments here:

Your comments will be displayed after verification.