C Programming :: String - Discussion
Home > C Programming > String > MCQs Questions Discussion
2 / 26
What is the output of the following problem ?
#include<stdio.h>
int main()
{
char *str = "12345";
printf("%c %c %c\n", *str, *(str++), *(str++));
return 0;
}
#include<stdio.h>
int main()
{
char *str = "12345";
printf("%c %c %c\n", *str, *(str++), *(str++));
return 0;
}
A3 2 1
B1 2 3
C3 4 5
DCompilation Error
ENone of these
Answer: Option (Login/Signup)
Show Explanation
So output is 321.
Asked In ::
The contents in printf are stored in the form of stack. So first right most variable i.e *(str++) is executed which prints '1' and address gets incremented.next *(str++) executes which prints '2' and finally executes*str which prints '3'.printing of values is done same as given in the printf function.
So output is 321.
Read Full Answer
Report Error
Please Login First Click Here