-->

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;
}

WAP to understand type casting.

// program to understand type conversion
#include <iostream>
#include<stdlib.h>   // to handle system("cls")
using namespace std;
int main()
{
    system("cls");
    int a;
    int b;
    float result;
    cout<<"a and b="<<endl;
    cin>>a>>b;              //multiple inputs using >> operator called 'extraction' or 'get from' operator. 'cin' is an object.
    result=(a*b)/2;        // type casting takes place. It is implicit.
    cout<<"implicit result ="<<result<<endl;// gives result 8 if we input 1 and 17.
    result=float(a*b)/2;    // type casting takes place (Explicit).
    cout << "explicit result=" <<result<< endl;//gives result= 8.5 if we input 1 and 17
    return 0;
}

WAP to understand library function.

//program to understand library function
#include <iostream>// header file
#include<cmath>     // header file to handle mathematical functions
using namespace std;//to handle all standard characters/functions,reserved words  used in program. we do not use in turboc++ compiler
int main()
{
    double number,number_square;// declaration of variables
    cout << "enter a number" << endl;// input message
    cin>>number;                    // accepts input
    number_square=pow(number,2);    // finds square and stores in variable
    cout<<"square ="<<number_square;// prints output.
    return 0;
}

WAP to understand setw() function.

//program to understand setw() function   //comment line
#include <iostream>              // header file to handle input and output
#include<stdlib.h>               //header file to handle return statement.
#include<iomanip>
#include<conio.h>
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 as starting point of execution
{

    system("cls");                     // clears the screen. It exists in stdlib.h
    cout<<setw(17)<<"first line"<<endl;// setw creates a box of 17 widths to put given string
    cout<<setw(17)<<"second line"<<endl;//setw creates a box of 17 widths to put given string
    cout <<setw(17)<<"Hello world!" << endl;// cout is an object and is pre-defined. It is responsible for output stream. endl is to end the line.
                                   //<< is called insertion operator or put -to operator.
    return 0;                       // returns 0.
}

WAP to print character constant.

//program to print character constant    //comment line
#include<iostream>              // header file to handle input and output
#include<stdlib.h>
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 as starting point of execution
{
    char value='s';
    cout<<"value="<<value<<endl//endl is a manipulator and causes a linefeed
    <<"second line"<<value;// cout is an object and is pre-defined. It is responsible for output stream. endl is to end the line.
                                   //<< is called insertion operator or put -to operator.
    return 0;                       // the string inside double quote is string constant. Here it is "hello world".
}