C++ Program Results in Corresponding Output Based on User Input - Wisdom Lighter

Sunday, 1 July 2018

C++ Program Results in Corresponding Output Based on User Input



Write a program to get input a number, lets say your age form keyboard and check it. 
Condition                                                                Message
age is less than 50                                       "You are pretty young!"
age is equal to 50                                            "You are old"
age is greater than 50                                   "You are really old"'

#include <iostream>
#include <stdio.h>
#include <conio.h>

using namespace std;

int main ()

{

  int age ;
  cout << " Enter the age of the person " << endl ;
  cin >> age ;

  if ( age < 50) {

      cout << " you are pretty young! " << endl;

  } else if (age == 50) {

  cout << "you are old " << endl;

  } else {

  cout << "you are really old" << endl;

  }


  getch();

}

No comments:
Write comments