Question
Check if a person can vote and also check if they are a senior citizen using nested if.
Solution
β Verified
#include <stdio.h>
int main() {
int age;
printf("Enter your age: ");
scanf("%d", &age);
if (age >= 18) {
printf("You are eligible to vote.\n");
if (age >= 60) {
printf("You are also a senior citizen.\n");
} else {
printf("You are not a senior citizen.\n");
}
} else {
printf("You are not eligible to vote.\n");
}
return 0;
}
Click here to download practice questions on
If Else StatementMore Questions on If Else Statement
Question 7
Write a program in C to Check whether a character is uppercase or lowercase.
View solution
Question 12
Write a program in C to Check if a person is eligible to vote by checking his or her age.
View solution