main()
{
int i=5;
printf("%d%d%d%d",i++,i--,i);
}

Answers were Sorted based on User's Feedback



main() { int i=5; printf("%d%d%d%d",i++,i--,i); }..

Answer / vara

4 5 5 and garbagevalue

Is This Answer Correct ?    12 Yes 4 No

main() { int i=5; printf("%d%d%d%d",i++,i--,i); }..

Answer / mani

4 5 5

Is This Answer Correct ?    1 Yes 0 No

main() { int i=5; printf("%d%d%d%d",i++,i--,i); }..

Answer / sravan kumer

Answer is 455848 in 'Turbo C++'
because here gave 4 %d's but given variables to print are 3.
So here Turbo C++ will evaluate first 3 parameters given as
---> first i will be evaluated so i=5 because printf() evaluates from right to left.
---> then i-- is 5 because it is post decrement so 1st prints value and then increments i=4
---> then i++ is post increments so 1st prints i value i.e 4
and then it will be incremented to 5.
---> so it printf will print 455 but there is another %d ,printf will handle those with a garbage values i.e 848 here.
so answer is 455848.i.e 455 is common after that some garbage value will be printed.

Is This Answer Correct ?    1 Yes 0 No

main() { int i=5; printf("%d%d%d%d",i++,i--,i); }..

Answer / ajay karanam

4554202496

Is This Answer Correct ?    3 Yes 5 No

main() { int i=5; printf("%d%d%d%d",i++,i--,i); }..

Answer / pranu

655

Is This Answer Correct ?    2 Yes 4 No

main() { int i=5; printf("%d%d%d%d",i++,i--,i); }..

Answer / vignesh1988i

some garbage value , 4,5,5...

why in this o/p garbage value is because only 3 parameters
are passed but we have assigned 4 control strings , where
one control string is useless, so for that compiler will
print garbage value....

Is This Answer Correct ?    2 Yes 4 No

main() { int i=5; printf("%d%d%d%d",i++,i--,i); }..

Answer / rukmanee

i++=5
i--=5
i=5

Is This Answer Correct ?    1 Yes 3 No

main() { int i=5; printf("%d%d%d%d",i++,i--,i); }..

Answer / sravankumar

printf() function evaluates from right to left

printf("\n %d %d %d",i++,i--,i);
4 5 5
<- <- <- <- <-evaluation of expression
but prints as the way we mentioned in printf() function
i.e first i = 5
then i--= 5 because it is post decrement
then i++= 4 this because i is decremented in above, and
not incremented immediately because is post
increment
So output is : 4 5 5

Is This Answer Correct ?    0 Yes 3 No

main() { int i=5; printf("%d%d%d%d",i++,i--,i); }..

Answer / sunil5a2

4 5 5

printf excutes form lefthand side onwords..

Is This Answer Correct ?    0 Yes 5 No

main() { int i=5; printf("%d%d%d%d",i++,i--,i); }..

Answer / cholan

55545

Is This Answer Correct ?    0 Yes 10 No

Post New Answer

More C Interview Questions

question-how to run a c programme.

6 Answers  


What is I ++ in c programming?

0 Answers  


1.what are local and global variables? 2.what is the scope of static variables? 3.what is the difference between static and global variables? 4.what are volatile variables? 5.what is the use of 'auto' keyword? 6.how do we make a global variable accessible across files? Explain the extern keyword? 7.what is a function prototype? 8.what does keyword 'extern' mean in a function declaration?

2 Answers   nvidia,


What are the disadvantages of external storage class?

0 Answers  


What is the use of pragma in embedded c?

0 Answers  






List some applications of c programming language?

0 Answers  


How can I prevent other programmers from violating encapsulation by seeing the private parts of my class?

1 Answers  


What is the memory allocated by the following definition ? int (*x)();

2 Answers   ADITI,


Differentiate between calloc and malloc.

0 Answers   Wipro,


Can true be a variable name in c?

0 Answers  


What do the functions atoi(), itoa() and gcvt() do?

0 Answers   Aspire, Infogain,


Want to know how to write a C program that connects to a MySQL server and checks if the InnoDB plug-in is installed on it. If so, your program should print the total number of disk writes by MySQL.

0 Answers  


Categories