Simple If – Senior Citizen Test
Taking age as input and finding if it is greater or equal to 60.
Learning Objectives
- Learning to make a selection of instructions to be executed when certain condition given after the if is true.
- Only the instruction after the the condition is true is done here.
Source Code
|
Run Output
Code Understanding
int age; cout<<“Give your age :”; cin>>age;
Collecting the age of person as an integer variable.
if(age >=60)
Testing if the age is more or equal to 60. This is an incomplete instruction as an if instruction is completed by its statement of truthness immediately following it or within curly braces block after it.
cout<<“You are a senior citizen”<<endl;
Printing the message for a senior citizen. This is the statement which is followed when condition given after the if is true.
Notes
- Concept of age for a senior citizen to be 60 may be different in different countries or schemes there off.
Suggested Filename(s): simpleif.cpp, seniorcitizen.cpp
sunmitra| Created: 22-Dec-2017 | Updated: 15-Sep-2018|