|
|
|
Nested if-else Statement
% cat fish_if.cpp
#include<iostream>
using namespace std;
int main()
{
char resident;
int age, fee;
cout << "Enter the age of the person: ";
cin >> age;
cout << "Enter y if the person is a resident, n otherwise: ";
cin >> resident;
fee = 50;
if(resident == 'y')
{
if (age >= 65 )
fee = 25;
}
else
fee = 100;
cout << "The fishing license fee is $" << fee <<
endl;
return 0;
}
What happens if you remove the braces in the if-else statement?
TRY IT!
|
|