Skip to main content

Prefix and Post fix

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

Popular posts from this blog

White space in PHP

White space in PHP : <html> <head> <title>My First PHP Page</title> </head> <body> <?php echo "Hello World!";                  /*As with HTML, whitespace is ignored between PHP statements.                                       This means it is OK to have one line of PHP code, then 20 lines of blank space                                       before the next line of PHP code. You can also press tab to indent your code and                                       the PHP interpreter will ignore those spaces as well. like from line 9 to line                      ...

Assign Values to Variables

#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; main()                 // it is the start of you your programe its means form here you will                        // start the coding . .  comouter only understand this main                       { int a=3,b=5;      /* Now what is  int a=3, b=5; as you are now full aware of (int)                   and (variable) but this  is some thing difficult. .  wait a minute                   its not difficult.*/ cout<<a<<endl; cout<<b<<endl;      /* as i discussed...

basic syntax of c++

Basic syntax of c++  #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; main()                 // it is the start of you your program its means form here you will                        // start the coding . .  computer only understand this main                       {                      // starting your program  from starting cout<<"here is my first program in c++ "; // cout mean show me . . . << mean the thing infront of this <<                                          // ...