What is an increment operator in C?

Asked: Garima Thapa


Ram Krishna

Increment operator in C

In C programming ++ is used as increment operator, Increment operator is used to increasing the value of a variable by 1, It is always used with a numeric type variable. It can be written in two ways.

variable ++

++ variable

The meaning of both types is the same i.e. variable=vaiable+1, Let's understand with examples.

Example 1

int a=20;


printf("Now the value of a is %d",a);


Now the value of a is 21

Example 2

int b=20;


printf("Now the value of b is %d",b);


Now the value of b is 21


In both examples you can see that, when we used a++ then it increases the value of a by 1, and when we used ++b then it also does the same thing i.e. it also increases the value of b by 1.

So simply 

a++ means a=a+1 

++b means b=b+1

0 votes

Your Answer

Email Us: advertise@gdatamart.com

Donate Us: Support to GDATAMART

© 2023 GDATAMART.COM (All Rights Reserved)