Increment and Decrement Operator are unary in nature i.e. it require single operand to perform an operation.Increment operator is represented by "++" while decrement operator is represented by "--".
Increment-: Pre increment [ ++i ]
Post increment [ i++ ]
Decrement-: Pre decrement [ -- i ]
Post decrement [ i -- ]
Increment operator increments the value of operands by 1 while decrement operator decrements the value of an operands by 1. ads
Increment operator:-
#include<stdio.h>
#include<conio.h>
void main()
{int x,i;
i=10;
x=++i + i++;
printf("x: %d",x);
printf("i: %d",i);
getch();
} output-: i=12
x=22
Decrement operator:-
#include<stdio.h>
#include<conio.h>
void main()
{int x,i;
i=15;
x=i-- + --i;
printf("x=%d",x);
printf("\n i=%d",i);
getch();
} output-: i=28
Are my blogs helpful to you..
ReplyDeleteYes your blog are helpful
ReplyDelete