Input two numbers. Use if statement to compare - C++ Statement

C++ examples for Statement:if

Description

Input two numbers. Use if statement to compare

Demo Code

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

int main(int nNumberofArgs, char* pszArgs[])
{
    int nArg1;/*from www  .jav  a  2 s. co  m*/
    cout << "Enter arg1: ";
    cin  >> nArg1;

    int nArg2;
    cout << "Enter arg2: ";
    cin  >> nArg2;

    if (nArg1 > nArg2) {
        cout<< "Argument 1 is greater than argument 2" << endl;
    }
    else
    {
        cout<< "Argument 1 is not greater than argument 2" << endl;
    }
    return 0;
}

Result


Related Tutorials