Sunday, 29 April 2012

Program Of Unary Operators In C++


#include<iostream.h>
#include<conio.h>
main()
{
clrscr();
int a,b,c,d,e,f,g,h;
a=10;
b=++a;    //b=11 , a=11
c=--a;   //c=10 , a=10
d=a--;   //d=10, a=9
e=a++;   //e=9,a=10
f=a++;  //f=10 , a=11
g=++a;  //g=12, a=12
h=a--;  //h=12, a=11
cout<<"\n a="<<a;
cout<<"\n b="<<b;
cout<<"\n c="<<c;
cout<<"\n d="<<d;
cout<<"\n e="<<e;
cout<<"\n f="<<f;
cout<<"\n g="<<g;
cout<<"\n h="<<h;
getch();
}
-----------------------------------------------
Define Unary Operator

Unary operators operate on one operand(variable or constant). There are two types of unary operators- increment and decrement.

No comments:

Post a Comment