(Increment ++ and Decrement-- Operator as Prefix and Postfix)
In programming, Increment++ operator increases the value of a variable by 1 and Decrement-- operator decreases the value of variable by 1
Suppose, a=5
Then, . ++a; //a becomes 6
a++; //a becomes 7
––a; //a becomes 6
a––; //a becomes 5
(Unary Operator)
The operator which operates on single operand (i.e, to perform an operation through these operators, We need only one operand).
(Program/Coding)
//Write a C program to Unary operator increment/decrement
#include<studio.h>
#include<conio.h>
void main ()
{
int a,b,c,d,e,f,g;
clrscr();
a=5;
b=a++;
printf("Post increment value of A=%d",b);
d=a;
c=++a;
printf("\n Pre increment value of A=%d",c);
printf("\n A present values is=%d",d);
e=a––;
printf("\n Post decrement value A is=%d",e);
g=a;
printf("\n Decrement present value is=%d",g);
f=––a;
printf("\n Pre increment value A is=%d",f);
getch();
}
In programming, Increment++ operator increases the value of a variable by 1 and Decrement-- operator decreases the value of variable by 1
Suppose, a=5
Then, . ++a; //a becomes 6
a++; //a becomes 7
––a; //a becomes 6
a––; //a becomes 5
(Unary Operator)
The operator which operates on single operand (i.e, to perform an operation through these operators, We need only one operand).
(Program/Coding)
//Write a C program to Unary operator increment/decrement
#include<studio.h>
#include<conio.h>
void main ()
{
int a,b,c,d,e,f,g;
clrscr();
a=5;
b=a++;
printf("Post increment value of A=%d",b);
d=a;
c=++a;
printf("\n Pre increment value of A=%d",c);
printf("\n A present values is=%d",d);
e=a––;
printf("\n Post decrement value A is=%d",e);
g=a;
printf("\n Decrement present value is=%d",g);
f=––a;
printf("\n Pre increment value A is=%d",f);
getch();
}
Comments
Post a Comment
Please Subscribe and Comments my blog site.