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

Answer Posted / sheetal

gives error
"error C2105: '++' needs l-value"
because it parses above expression in "((i++)++)+i), so in
2nd unary operator it searches for l-value.
If we modify above pgm into following way:-
void main()
{
int i=5;
printf("%d",((i++)+(++i)));
}
it will give answer 12.
because once last pre-unary increment operator is operated,
i is incremented to 6 and 6+6 = 12.
if we put one more print for i's value, it will give i =7.
because first post-increment operator is operated after
first printf statement as follows.
void main()
{
int i=5;
printf("%d",((i++)+(++i)));
printf("%d\n",i); // ===> i =7
}

Is This Answer Correct ?    4 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why functions are used in c?

584


Write a program to display all the prime nos from 1 to 1000000, your code should not take time more than a minute to display all the nos.

1591


What is the maximum length of an identifier?

665


What's the total generic pointer type?

614


When was c language developed?

703






Describe the complexity of Binary search, Quicksort and various other sorting and searching techniques..

646


Explain logical errors? Compare with syntax errors.

622


Function calling procedures? and their differences? Why should one go for Call by Reference?

631


write a C program: To recognize date of any format even formats like "feb-02-2003","02-february-2003",mm/dd/yy, dd/mm/yy and display it as mm/dd/yy.

3335


What is bubble sort technique in c?

592


What is the purpose of void pointer?

594


Program will then find the largest of three numbers using nested if-else statements. User is prompted to enter three numbers. Program will find the largest number and display it on the screen. All three numbers entered by the user are also displayed. If user enters 21, 33, and 5, the output should be as follows: You entered: 21, 33 and 5. The largest number is 33.

1014


can anyone please tell about the nested interrupts?

1674


#include main() { char s[] = "Bouquets and Brickbats"; printf(" %c, ",*(&s[2])); printf("%s, ",s+5); printf(" %s",s); printf(" %c",*(s+2)); }

666


What is extern storage class in c?

509