TOP CATEGORIES

×

What is an increment operator in C?

R

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;

a++

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

Output

Now the value of a is 21

Example 2

int b=20;

++b

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

Output

Now the value of b is 21

Explanation-

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: advertise@gdatamart.com

Donate: To Support US

© 2024 GDATAMART.COM (All Rights Reserved)