C Program to Print Messages according to Age

Write a program to accept the age of a school student and print appropriate messages

Age 5 to 7 – “Sub Junior”
Age 8 to 10 – “Junior”
Age 11 to 13 – “Senior”
Age 14 to 17 – “Super Senior”
Age 18 and above – “Not A School Student”

Code:

#include<stdio.h> int main(){ int age; scanf("%d",&age); if(age>=5 && age<=7) printf("Sub Junior"); else if(age>=8 && age<=10) printf("Junior"); else if(age>=11 && age<=13) printf("Senior"); else if(age>=14 && age<=17) printf("Super Senior"); else if(age>=18) printf("Not A School Student"); return 0; }
Code language: C/AL (cal)

Output:

7 Sub Junior 17 Super Senior 20 Not A School Student

Leave a Comment