C Language program to take age and tell whether its infant or child or adult


Following program shows you how to take age and tell whether its infant or child or adult.
In this program we get age from user, and if the age is less than or equal to 0 it prints invalid input, and if the age is between 1 to 5 it shows infant and if the age is between 6 to 10 it prints child otherwise it prints adult

#include <stdio.h>
int main(void) {
	int age;
	printf("Please enter age:");
	scanf("%d", &age);
	if (age <= 0) {
		printf("Invalid input");
	} else if (age >= 1 && age <= 5) {
		printf("Infant");
       } else if (age >= 6 && age <= 10) {
               printf("Child");
	} else {
		printf("Adult");
	}
}

Output:

Example1:

Please enter age: 
 3
Infant 

Example2:

Please enter age: 
 8
Child 

Example3:

Please enter age: 
 23
Adult 

Example4:

Please enter age: 
 -4
Invalid input