Pages

C++ Programming Tutorials - 6 (Constants,Manipulators & Operator Precedence)

tut9.cpp =

// This tut contains Constants,Manipulators & Operator Precedence
#include<iostream>
#include<iomanip>
using namespace std;

int main(){
    int a=25;
    cout<<"The value of a was :"<<a<<endl;
    a=45;
    cout<<"The value of a is :"<<a<<endl;

    //**********************Constants in C++************************

    const int b=35;
    cout<<"The value of b was :"<<b<<endl;
    //b=36;
    cout<<"The value of b was :"<<b<<endl;

    //*********************Manipulators in C++**********************

    int p=3,q=78,r=1233;
    cout<<"The value of p without setw is"<<p<<endl;
    cout<<"The value of q without setw is"<<q<<endl;
    cout<<"The value of r without setw is"<<r<<endl;

    cout<<"The value of p with setw is :"<<setw(4)<<p<<endl;
    cout<<"The value of q with setw is :"<<setw(4)<<q<<endl;
    cout<<"The value of r with setw is :"<<setw(4)<<r<<endl;

    //********************Operator Predence*************************
    int x=3,y=4;
    int z=((((x*5)+y)-45)+87);
    cout<<"z :"<<z
    return 0;
}

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Top 10 Python Packages Every Developer Should Learn

Top 10 Python Packages Every Developer Should Learn There are more than  200,000 Python packages  in the world (and that’s just counting tho...