-->

WAP to understand logical operator.

//PROGRAM TO UNDERSTAND following logical operators
/*
and operator        &&
or operator         ||
not operator        !
*/
#include <iostream>//header file
#include<stdlib.h>//header file to handle system("cls")

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 number1,number2;
    cout<<"enter two numbers"<<endl;//prints message to input numbers
    cin>>number1>>number2;          //gets inputs using chaining concept
    system("cls");                  //clears the screen
    cout<<"number1="<<number1<<endl<<"number2="<<number2<<endl;
    cout<<"result of (number1>=20 && number2<=50):-"<<(number1>=20 && number2<=50)<<endl;
    //returns 0 or 1(after testing both conditions) depending upon they are  false or true.Actually, it multiplies both results and returns 0/1.
    cout<<"result of (number1>=20 || number2<=50):-"<<(number1>=20 || number2<=50)<<endl;
    //returns 0 or 1(after testing both conditions) depending upon they are  false or true.
    //Actually, it adds both results and returns 0/1.
    cout<<"result of (!number1>20):-"<<!(number1>20)<<endl;
    //returns 0 or 1 if it is true or false.
    return 0;
}

WAP to understand relational operator.

//program to understand following relational operators
/*
1)greater than                  (>)
2) greater than or equals to    (>=)
3)smaller than                  (<)
4) smaller than or equals to    (<=)
5)equals to                     (==)
6) not equal to                 (!=)
*/
#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;
    cout << "enter a number" << endl;
    cin>>number;
    cout<<"number<20:-"<<(number<20)<<endl;//returns 0 or 1 if it is false or true
    cout<<"number<=20:-"<<(number<=20)<<endl;//returns 0 or 1 if it is false or true
    cout<<"number>20:-"<<(number>20)<<endl;//returns 0 or 1 if it is false or true
    cout<<"number>=20:-"<<(number>=20)<<endl;//returns 0 or 1 if it is false or true
    cout<<"number!=20:-"<<(number!=20)<<endl;//returns 0 or 1 if it is false or true
    cout<<"number==20:-"<<(number==20)<<endl;//returns 0 or 1 if it is false or true
    return 0;
}
//note:kindly put parentheses for expression(number<20); if we do not put then it does not work.

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
}