C++ Standard Input Read int value from keyboard

Description

C++ Standard Input Read int value from keyboard

#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;

int main(int nNumberofArgs, char* pszArgs[])
{
    // set output format for bool variables to true and false instead of 1 and 0
    cout.setf(cout.boolalpha);/*from w  w w.  ja va 2  s.c o m*/

    int nArg1;
    cout << "Input value 1: ";
    cin >> nArg1;

    int nArg2;
    cout << "Input value 2: ";
    cin >> nArg2;

    bool b;
    b = nArg1 == nArg2;

    cout << "The statement, " << nArg1
         << " equals "        << nArg2
         << " is "            << b
         << endl;

    return 0;
}



PreviousNext

Related