C
Programming and Technical
Programming
Program
#include
int main(){
int a=2;
a=a++ + ~++a;
printf("%d",a);
return 0;
}
Read Solution (Total 14)
-
- a++, here it is post increment so it takes value as 2 then it will increments.
++a, here it is pre increment so it increments first hence value is 4 and ~4 will be -4-1=-5 then a=2+(-5)=-3
so it will print -3. - 10 years agoHelpfull: Yes(9) No(4)
- result is 0
- 10 years agoHelpfull: Yes(7) No(3)
- ans=-3
2+~4
2+(-4-1)=2-5
=-3 - 10 years agoHelpfull: Yes(4) No(1)
- it will give -1 as output, as ~++a= -(++a)+1.
so, a++ + ~++a= 2+~4= 2+(-4+1)=-1 - 10 years agoHelpfull: Yes(3) No(0)
- a++ is 3
++a,here first increment then then take value i.e 4
3+4=7 - 9 years agoHelpfull: Yes(1) No(1)
- first we have to evaluate from right to left.so,
a=a++ + ~++a=>a=3 + -4=-1(~3=-3-1=-4).
so post increment of a will increment after assigning -1 to variable a.
finally it will print 0.
- 9 years agoHelpfull: Yes(1) No(1)
- can u plz explain it
- 10 years agoHelpfull: Yes(0) No(0)
- the ++a value may be 4 because a=2 is incremented by a++
- 10 years agoHelpfull: Yes(0) No(3)
- answers is 0
- 10 years agoHelpfull: Yes(0) No(2)
- it will give 0 .
- 10 years agoHelpfull: Yes(0) No(2)
- a=2-4 = -2
- 10 years agoHelpfull: Yes(0) No(2)
- Answer is 0.
- 10 years agoHelpfull: Yes(0) No(2)
- first it will increase value i.e ++a is 3 ,~3=-4,
now 4-4=0..
so ans is 0.
- 9 years agoHelpfull: Yes(0) No(1)
- 13 is answer.
- 6 years agoHelpfull: Yes(0) No(0)
C Other Question