Tuesday, March 31, 2015

Simple if example

Script

#include <iostream>
using namespace std;
#include <cmath>

int main()
{
        double yourage;

        cout << "Please enter your age:  ";
        cin >> yourage;

        cout << "You are " << yourage << " years old\n";

        if (yourage < 18)
                cout << "Oh!!! You are VERY young \n";
        return 0;
}


Execution

Please enter your age:  17
You are 17 years old
Oh!!! You are VERY young



Please enter your age:  47
You are 47 years old



Please enter your age:  35
You are 35 years old






No comments:

Post a Comment