Write a C-program to print age with following condtions
0-12 child age
12-19 teen age
19-40 younger age
40-80 old age
80-100 too old age
above 100 invalid
-11 negative age
#include <stdio.h>
int main() {
int age;
printf("Enter Your Age");
scanf("%d",&age);
if(age>0 && age<=12)
{
printf("You are a child");
}
else if(age>12 && age<=19)
{
printf("You are a teenager");
}
else if(age>19 && age<=40)
{
printf("You are younger");
}
else if(age>40 && age<=80)
{
printf("You are old");
}
else if(age>8 && age<=100)
{
printf("You are too old");
}
else if(age>100)
{
printf("Invalid");
}
else
{
printf("Age should not be negative");
}
return 0;
}
Output:
Enter Your Age 24
You are younger
Enter Your Age 10
You are a child
Enter Your Age -24
Age should not be negative
More Programs
36 . Write a C-program to print age
37 . Write a C-program to print max number among three numbers
38 . Write a C-program to print 1 to 10 values using for loop
39 . Write a C-program to print 10 to 1 values using for loop
40 . Write a C-program to print 1 to n values using for loop
41 . Write a C-program to print even numbers using for loop
42 . Write a C-program to print even number or odd number based on the n value using for loop
43 . Write a C-program to print even number or odd number based on the n value using single for loop
44 . Write a C-program to count the number of divisible numbers in a given range(1-100)
45 . Write a C-program to print count the number of divisible numbers in a given range(1-100) without using loop
46 . Write a C-program to print factorial number using for loop