-->

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".
}

WAP to understand definition of variables.

//program to understand definition of variables
#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;  //declaration of variable.
     number=90;//definition of variable
    cout << "number =" <<number<< endl;
    return 0;
}

WAP to understand character variable and constant.

//program to understand character variable and constant
#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
{
    char a='r';        //declaration and value assignment(initialization). We put inside single quote.
    cout << "character="<<a << endl;//value printing
    return 0;
}

WAP to print multiple string using single cout.

//program to print multiple string using single cout object.
#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()
{
    cout << "first line" << endl
        <<"second line"<<endl
        <<"third line"<<endl; //We have used only one cout .
                              //It is also called chaining concept. Keep in mind, put semi-colon at the last of statement.
    return 0;                   // otherwise it will not work.
}

WAp to input string

// program to understand string input in C++ using string data type
#include<iostream>
#include<stdlib.h>
using namespace std;
int main()
{
    string name;    //string data type to accept string. We can not write identifier value i.e name[30].
                    // If we write then we should use char name[30].
    system("cls");  // clears the screen
    cout<<"enter name"<<endl;// cout object to print message.<< is also called insertion operator.
    getline(cin,name);     // accepts name using 'get from' operator (>> or extraction operator) with space.
    cout<<"name="<<name<<endl;// prints input values/string/name.
    cout<<"enter name again"<<endl;//prints the literal
    cin>>name;// accepts name without space.
    cout<<"name="<<"without space is:-"<<name;//prints name
    return 0;

}

WAP to input using cin.

// program to understand cin object in C++
#include<iostream>
#include<stdlib.h>
using namespace std;
int main()
{
    system("cls");  // clears the screen
    int a,b;        //declaration of variables
    cout<<"enter values for a and b"<<endl;
    cin>>a>>b;// multiple inputs using 'get from' operator (>>). we can use in different line.
    cout<<"a="<<a<<" and b="<<b<<endl;// prints input values in same line with string literal. we can use different line.
    return 0;                         // it is also called chaining outputs/inputs
}

WAP to input

// program to understand cin object in C++
#include<iostream>
#inlcude<stdlib.h>
using namespace std;
int main()
{
    system("cls");
    int a,b;
    cout<<"enter values for a and b"<<endl;
    cin>>a>>b;
    cout<<"a="<<a<<"and b="<<b<<endl;
    return 0;
}