-->

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

WAP to use header file with double quote.

//program to understand header file with double quote
#include "iostream"  //header file enclosed inside double quote
#include"stdlib"     // header file for system("cls")
using namespace std;
int main()
{

    cout << "Hello world!" << endl; // cout object with insertion operator/put to operator(<<)
    cout<<"this is second line"<<endl;
    return 0;
}

WAP to understand white space

//program to understand white space
#include <iostream>                 //header file
#include<stdlib.h>                  //header file
using namespace std;
int main()                          //main function
{
    cout << "Hello C++!" << endl;// string print with space called white space. It also can be tab/line feed
                                    //vertical tab or formfeeds etc.
    return 0;                       // returns 0 after execution
}

WAP to understand escape sequence.

//PROGRAM TO understand escape sequence

#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 << "first line"<<"\n";//escape sequence for new line
    cout<<"second line"<<"\n";//escape sequence for new line. we can also use single quote. It works.
    return 0;
}

WAP to understand endl manipulator

// program to understand endl manipulator
#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;// cout is an object and is pre-defined. It is responsible for output stream.
                             // endl is used to feed a line in stream and is called manipulator. It works in same manner as \n does in program.
                            // we can put \n in single quote or double quote.
    cout << "second line\n";
    cout<<"third line"<<"\n"<<"or"<<endl;
    cout<<"fourth line"<<'\n';
    return 0;
}

c++ to print hello world

//program to print hello world    //comment line
#include <iostream>              // header file to handle input and output
#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 as starting point of execution
{
    cout<<"firstline"<<endl;
    system("cls");                 //clears the screen
    cout << "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;                       // the string inside double quote is string constant. Here it is "hello world".
}

c++ basic programs

We have following basic programs.
----------------------------------------------------------------------------------------
1)wap to print hello world.
                                                                                                 solution

2)WAP to understand endl.

                                                                                                solution

3)WAP to understand escape sequence.

                                                                                               solution

4)WAP to understand white space.

                                                                                              solution

5)WAP to use header file with double quote.

                                                                                                    solution

6)WAP to input.
                                                                                               solution

7)WAP to input using cin.

                                                                                                 solution

8)WAp to input string .

                                                                                                     solution

9)WAP to print multiple string using single cout.

                                                                                                solution

10)WAP to understand character variable and constant.

                                                                                                     solution

11)WAP to understand definition of variables.

                                                                                                   solution

12)WAP to print character constant.

                                                                                                solution

13)WAP to understand setw() function.

                                                                                               solution

14)WAP to understand library function.
     
                                                                                                solution

15)WAP to understand type casting.

                                                                                                solution

16)WAP to understand assignment operator.

                                                                                                 solution

17)WAP to understand const identifier.

                                                                                               solution

18)WAP to understand define directive or symbolic constant.

                                                                                                solution

19)WAP to understand arithmetic remainder operator.

                                                                                                solution

20)WAP to understand unary operator(prefix and postfix).

                                                                                                solution

21)WAP to generate given table using single cout.

                                                                                                solution

22)Program to generate given output.

                                                                                              solution

23)WAP to understand relational operator.

                                                                                              solution

24)WAP to understand logical operator.

                                                                                            solution

25)WAP to understand conditional operator.

                                                                                            solution

26)WAP to clear the screen using system(cls).

                                                                                            solution

27)WAP to add two numbers without using namespace.

                                                                                            solution

28)WAP to print hello world without namespace.

                                                                                            solution


-----------------------------------------------------------------------------------------
If you find broken link, please let me know.