#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


Please Help Members By Posting Answers For Below Questions

Write a function which takes as parameters one regular expression(only ? and * are the special characters) and a string and returns whether the string matched the regular expression.

645


What does node * mean?

705


What are dangling pointers? How are dangling pointers different from memory leaks?

617


How many bytes is a struct in c?

721


Explain what would happen to x in this expression: x += 15; (assuming the value of x is 5)

805






What is break in c?

582


Is there a way to switch on strings?

610


Write a program to print "hello world" without using a semicolon?

591


What is volatile variable in c with example?

581


we called a function and passed something do it we have always passed the "values" of variables to the called function. such functions calles are called a) calls by reference b) calls by value c) calls by zero d) none of the above

632


What are the different types of data structures in c?

596


in iso what are the common technological language?

1631


What is the total generic pointer type?

722


How to declare pointer variables?

683


How is a null pointer different from a dangling pointer?

555