what is the output for this question:
main()
{
int i=1;
printf("%d%d%d",i,i++,++i);
}

Answer Posted / rama krishna sidhartha

3,2,2 is the correct output. Because the the associativity
of ++ operator is from right to left.

since i=1

++i = 2(since it is a preincrement operator it is
incremented before printing the value)

i++ = 2(since it is a postincrement operator it is
incremented after printing the value)

i = 3

so it is displayed like 3,2,2.

Is This Answer Correct ?    8 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How would you rename a function in C?

625


What is volatile variable in c?

660


What is methods in c?

646


What are multibyte characters?

647


Explain heap and queue.

591






How can I implement a delay, or time a users response, with sub-second resolution?

630


What is extern storage class in c?

515


How to delete a node from linked list w/o using collectons?

2091


If you know then define #pragma?

678


What is header file in c?

607


Explain what happens if you free a pointer twice?

615


How can I avoid the abort, retry, fail messages?

665


What is bubble sort technique in c?

594


What is the difference between volatile and const volatile?

569


Why is main function so important?

619