Showing posts with label Increment and Decrement Operator. Show all posts
Showing posts with label Increment and Decrement Operator. Show all posts

Tuesday, 24 February 2015

Increment and Decrement Operator In C++

/*
Increment and Decrement Operator
===============================
++ - Increment Operator
-- - Decrement Operator

++a - Pre Increment
a++ - Post Increment

--a - Pre Decrement
a-- - Post Decrement

*/

#include<iostream.h>
#include<conio.h>
main()
{
int a=10,b;
clrscr();

b=a++;

cout<<"\n B value is "<<b;
cout<<"\n A value is "<<a;

b=++a;

cout<<"\n B value is "<<b;
cout<<"\n A value is "<<a;

b=a--;

cout<<"\n B value is "<<b;
cout<<"\n A value is "<<a;

b=--a;

cout<<"\n B value is "<<b;
cout<<"\n A value is "<<a;

getch();
}