C Programming - Input / Output - Discussion

Discussion Forum : Input / Output - Find Output of Program (Q.No. 3)
3.
What will be the output of the program ?
#include<stdio.h>
char *str = "char *str = %c%s%c; main(){ printf(str, 34, str, 34);}";

int main()
{
    printf(str, 34, str, 34);
    return 0;
}
char *str = "char *str = %c%s%c; main(){ printf(str, 34, str, 34);}"; main(){ printf(str, 34, str, 34);}
char *str = %c%s%c; main(){ printf(str, 34, str, 34);}
No output
Error in program
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
28 comments Page 2 of 3.

MASS said:   8 years ago
Awesome explanation, thank you all.

HARISH said:   8 years ago
Thanks @Kavyashree.

Amrit said:   8 years ago
I'm not getting this.

Please give a proper explanation.

Vishalakshi said:   9 years ago
Thanks @Vishnupriya.

Adi said:   9 years ago
Thank you @Vishnupriya.

Sharath said:   1 decade ago
Can anyone explain this please?

Siva sangeetha said:   1 decade ago
How could understand in easiest way?

"=asci value of 34.

Then str is? How and what will be correct?

Siva said:   1 decade ago
What is mean by char*string;? Could you explain please?

Anubhav singh (Funky) said:   1 decade ago
OK ! I can explain it in a easier way:

Consider the statement:-

printf("abc1 %c %s %c abc2", 10, xyz, 10);

You can see its a simple printf statement.

Now replace, abc1 => char *str =

abc2 =>; main(){printf(str, 34, str, 34);}

10=> 34.

xyz =>char*str = %c%s%c; main(){printf (str, 34, str, 34);}

You will get the answer.

Lakshmeesh said:   1 decade ago
Still I am facing problem in input and output statements.


Post your comments here:

Your comments will be displayed after verification.