-->
Showing posts with label WAP to understand setw() function.. Show all posts
Showing posts with label WAP to understand setw() function.. Show all posts

Tuesday, April 14, 2020

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