#include<stdio.h>
int main()
{
int i=2;
int j=++i + ++i + i++;
printf("%d\n",i);
printf("%d\n",j);
}
Answer Posted / sanjay
i = 5
j = 11
It is because during the first pre-increment "++i" the compiler gets the value from the memory, increments it and stores it in the memory ie now i = 3. During the second pre-increment "++i" the compiler again gets the value from the memory, increments it, (value in the memory was 3) and so the incremented value is stored again in memory ie i = 4. during the post increment, the value from the memory is received and used in the statement ie) (the whole final statement looks like this ->>( 3 + 4 + 4) ) and then value of i is incremented and stored in memory. thus finally the value of i is 5 and j is 11.
| Is This Answer Correct ? | 2 Yes | 0 No |
Post New Answer View All Answers
Why is this loop always executing once?
Explain how do you convert strings to numbers in c?
How many types of functions are there in c?
Write a code to achieve inter processor communication (mutual exclusion implementation pseudo code)?
Tell me what are bitwise shift operators?
How can you draw circles in C?
What do you mean by command line argument?
Take an MxN matrice from user and then sum upper diagonal in a variable and lower diagonal in a separate variables. Print the result
What is NULL pointer?
Can you add pointers together? Why would you?
What is boolean in c?
What does dm mean sexually?
PLS U SENS ME INTERVIEW O. MY EMAIL ADD, SOFIYA.SINGH@GMAIL.COM
What are header files in c?
Explain main function in c?