0
What is wrong with this code
Im trying to make a school acceptance and im having trouble when asking the age if the age is greater than 18 then the school reject and the same rule when underage and equal to 16 until 18 the school accept code: #include <iostream> using namespace std; int main() { int age; string name; cout << "Penerimaan siswa baru\n" << endl; cout << "Nama="; cin >> name; cout << "Umur="; cin >> age; if (age > 18) { cout << "Anda terlalu tua"; } if (age >= 16) { cout << "\n\nNama=" << name << "\n" << "Umur=" << age; cout << "\n\nAnda keterima"; } if (age < 16) { cout << "Anda dibawah umur"; } return 0; }
2 Answers
+ 3
Use else statement.
Do like this -
if(age<16){
cout<<"underage";
} else if(age>=16&&age<=18){
Print name and age here
} else{
cout<<"over age";
}
+ 2
thx it worked now đđ



