Increment and decrement operators in C & C++ ++a + ++a + ++a


Abhishek Saha says:

perl -e “$a = 10; $b = ++$a + ++$a + ++$a; print $b”

Peterolen says:

The result is actually _undefined._ You should never modify a variable multiple times in the same expression like that. If your compiler doesn’t show a warning I suggest you turn up the warning level. If you’re using GCC, MinGW or Clang you should at least use the -Wall compiler flag.

Yatin Arora says:

but when am compiling it over c it’s giving 37 in java 36 can you please explain, I know it’s compiler dependent, but tell me only for c. please reply

Rahul SEC says:


Swarnapudi Somesh says:

perfect stuff learned a lot bro thanks

rameshbabu rammi says:

i am also getting 37

Hari Krishna Reddy says:

i am getting 37 in my C compiler for the same code , plzz help me . i will mail the screen shot output if u want

Dhruv Suthar says:

int i=3,j;
j = ++i*++i*++i;
printf(“%d %d”,i,j);

Output is 6 150

How ???

Manoj Jangra says:

Explanation of answer 37
here it is using grouping method
b= (12+12)+13
a increase by 2 and reach at 12 then it will perform addition. After that it will reach at 13 and finally 24+13=37

Prathap karaka says:

i just compiled in i got 37

praveen padala says:

hi sir as far as my knowledge all the three operators are preincrement so according to associvity rule it should go from right to left not from left to right

snehal sonawane says:

Very nice
explanation sir!!!!!!

Krishna Thakur says:

Tell me name of company where you made this compiler plz stop these making bullshit type concept..

Gill Gill says:

I got 36 in java eclipse. Why so? Plz explain.

Sonu Prabhakar says:

Dear Sir, I use xcode for c programming and i am getting result 36. why?? and for a++ + a++ + a++, i am getting 33. plz answer me. why? xcode is not an older IDE? Then why is it showing like that?

Pramod Bhusal says:

why is the output different for ++a + ++a * ++a and ++a * ++a + ++a .pls can u explain

Chinki Laudha says: for computer question

Sneh Sharma says:

mere to iska output 37 hi aara h. manual bhi or compiler ke through bhi….

Snehajit Chandra Snehajit Chandra says:

please sir confusion dur kar dijiya

saahil nakami says:

int b = ++a + a++ + –a;
why is this an undefined behaviour

A R says:

PROGRAMS + VIDEO TUTORIALS + QUESTION ANSWERS and much more in a Single Android Application For C Language
click the link below to download the application,Its free.

abdellatif abdo says:

Amazing : But when we should use this technique ?

Nikhil Padole says: This might be useful to understand

Aqib Fayyaz says:


Hari Krishna Reddy says:

i sent the screen shots to your mail sir

Geeth Kavinda says:

i use codeblocks, i get 37

Surya Chakraborty says:

Can you tell me please what should be the answer
int a=10;
b=a++ + a++ + a++;
and exact what logic to be followed to compute prefix-post fix numericals?

Mudit Saxena says:

Answer is 37 dont use shitty compilers

Srinadh Srinadh says:

Good vedio

Gaurav singh rajawat says:

37 ans aa rha h

Arivazhagan S says:

in gcc it’s 37 and how do we get it…

Snehajit Chandra Snehajit Chandra says:

hi sir mera answer turbo c mei 39 but Mobile online compiler mei 37 aa rha hai.ek hi question ka do alag alag answer kaise aa sakta hai sir?

ABz News says:

Sir I have One Question:
When i am solve this Question then different C Compiler is Different Output
Plz Explain it.
void main()
int a=1,b;
b=a++ + ++a + ++a;
printf(“%d %d”,b,a);

Output in Turbo C++ 3.0 is : “b=9 and a=4”.
Output in Dev C++ 5.4.0 is : “b=7 and a=4”.
Output in Code Block 16.01 is : “b=8 and a=4”.

Khaled Awad says:

int a=10;
int b=++a + ++a + ++a;

 Write a comment


Do you like our videos?
Do you want to see more like that?

Please click below to support us on Facebook!