-->

Program to generate given output.

//program to generate following output.
/*
10
20
19
*/

#include <iostream>//header file

using namespace std;//to handle all standard characters/functions,reserved words  used in program. we do not use in turboc++ compiler.


int main()//main function
{
    int number=10;
    cout<<number<<endl;//prints 10
    number+=10;        //increses the value by 10
    cout<<number<<endl;//prints the 10
    cout<<--number;//prints 19 using prefix decrement operator.
    return 0;
}

WAP to generate given table using single cout.

//program to generate following table using single cout statement
/*
1990    135
1991    7290
1992    11300
1993    16200
*/

#include <iostream>//header file
#include<iomanip>//header file for manipulator(width to print)

using namespace std;//to handle all standard characters/functions,reserved words  used in program. we do not use in turboc++ compiler.
int main()//main function
{
    cout<<setw(4)<<"1990"<<setw(7)<<"135"<<endl
        <<setw(4)<<"1991"<<setw(7)<<"7290"<<endl
        <<setw(4)<<"1992"<<setw(7)<<"11300"<<endl
        <<setw(4)<<"1993"<<setw(7)<<"16200"<<endl;//we have used chaining concept.
                                                //for first column, we have used 4 boxes using setw(4) and
                                                //for second column, we have used 7 boxes. 5 boxes to print and 2 for space between columns.

    return 0;
}

WAP to understand unary operator(prefix and postfix).

//program to understand prefix and postfix operator
#include <iostream>//header file
using namespace std;//to handle all standard characters/functions,reserved words  used in program. we do not use in turboc++ compiler.

int main()          //main function
{
    int a=4,b;
    cout << "++a="<<++a << endl;//gives 5. It means first increase the value then use that. Its increased part (a=a+1) is invisible.
    a=4;
    cout<<"a++="<<a++;//gives 4. It means first use the value then increase the value. Its increased part is excuted after this statement and is not shown here.
                     // ++ is called increment operator. It can be prefix (++a)or postfix(a++).
    b=5;
   cout << "--a="<<--a << endl;//gives 4. It means first decrease the value then use that. Its decreased part (a=a-1) is invisible.
                    //-- is called decrement operator. It can be prefix(--a) and postfix(a--).
    b=5;
    cout<<"a--="<<a--;//gives 5. It means first use the value then decrease the value. Its decreased part is executed after this statement and is not shown here.
    return 0;
}

WAP to understand arithmetic remainder operator.

//program to understand remainder operator(modulus operator)

#include <iostream>//header file

using namespace std;//to handle all standard characters/functions,reserved words  used in program. we do not use in turboc++ compiler.

int main()          //main function
{
    cout << "remainder, when divided 5 by 7, is " <<5%7<<endl;
    return 0;
}

WAP to understand define directive or symbolic constant.

//program to understand define directive or symbolic constant
#include <iostream>//header file
#define name "RAM KUMAR KARKI"  //  defining symbolic constant for name
using namespace std;//to handle all standard characters/functions,reserved words  used in program. we do not use in turboc++ compiler.


int main()          //main function
{
    cout << "name="<<name << endl;//prints the name. Similarly we can also put numeric value.
    return 0;                       //returns zero value
}

WAP to understand const identifier

//program to understand const identifier

#include <iostream> //header file

using namespace std;//to handle all standard characters/functions,reserved words  used in program. we do not use in turboc++ compiler.


int main()             //main function
{
    const int a=90;         //declaration of variable with constant value
   // a=8;                // not allowed here; because const identifier
    cout << "value of a(constant)="<<a << endl;
    return 0;
}

WAP to understand assignment operator.

//program to understand assignment operator with contracted/condensed approach

#include <iostream>     //header file

using namespace std;//to handle all standard characters/functions,reserved words  used in program. we do not use in turboc++ compiler.

int main()              //main function
{
    int a;              //declaration
    a=56;               //value assignment
    cout << "the value of a=" <<a<< endl;//prints the value
    a+=4;                      //condensed method. it means a=a+4.
    cout<<"after adding 4 to 56, it is  "<<a;// prints the value after adding 4.
    return 0;
}