Question #180737

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.


Expert's answer

#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";
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS