A certain organization needs to elect its new president. So, they started looking for potential candidates. A candidate must be 30 to 40 years old and must be male in pursuance to its by-laws. Create a program that will ask the gender and age of the candidate applicant and will print if the applicant is accepted or rejected to be an official candidate. Use IF statements.
#include <iostream>
using namespace std;
int main() {
//ask fro gender and age from user
char gender;
int age;
cout<<"Enter Gender (M/F) : ";
cin>>gender;
cout<<"Enter Age : ";
cin>>age;
//validate gender and age
if(age>=30 && age<=40 && gender=='M'){
cout<<"Applicant is accepted";
}else{
cout<<"Applicant is rejected";
}
}
Comments
Leave a comment