15.9.15

comparison operator in c++

/* Use of Comparison Operator */

#include<iostream>
using namespace std;
string comparison(int age)
{
  string str;
  if(age<18)
    str="You are a child";
  else if(age>=18 && age<65)
    str="You are an adult";
  else if(age>=65)
    str="You are a senior citizen";
  return str;
}
int main()
{
    int age;
    cout<<"Enter Your Age to know who You are:"<<endl;
    cin>>age;
    cout<<comparison(age);
}

No comments:

Post a Comment

Comment Here