Can someone explain the concept of pre and post increment in C?

Please explain ++i and i++ use with example. It confuses me many times, which one increment its value first and when assigned?

  • Aditi
  • 27 नवम्बर
  • 4334 दृश्य
  • 3 उत्तर
Your Answer

Pre and Post increments are operators used in c language.In Pre increment operator(++a),the value of the variable is modified(incremented) first and then its value is assigned to the variable.eg
int a=2;
++a;
printf("%d",a);
Output:3
In post increment operator(a++),the value is first assigned to its variable and then modified(increased).
eg. int a=2;
a++;
printf("%d",a);
Output:2

c programming
मॉक परीक्षण अभ्यास के लिए
c programming