Prefix and Post fix
#include<iostream> // it is a library used for display#include<conio.h> // its is also a library used for input output statement
using namespace std;
// Prefix increment and post fix increment
main()
{
int a=3,b=4;
cout<<".........Prefix increment.........."<<endl;
cout<<"previous value of b="<<b<<endl; // as we know what is happening here
cout<<++b<<"=due to prefix increment"<<endl; /*as form the name prefix increment its increment value before using it in the program
like b=4 so ++b mean increment a value before its get use */
cout<<".........Post fix increment.........."<<endl;
cout<<"previous value of a="<<endl; // as we know what is happening here
cout<<"value of a is =\t"<<a++<<"\\t although ++ sign is there"<<endl;
cout<<"now here its get increment="<<a<<endl; /* here the value is first incremented then used in the program in the next
statement*/
}
/* Task:
Do same process with for the decrements operator use same codding but just replace ++ sign
with -- sign */
Comments
Post a Comment