+ 1
Following instructions to a point?
I have followed the instructions for question ; Nested if else statements. I have an error within the code playground explaining the following; ..\Playground\ :5:5: error: expected initializer before 'int' int age =18 ^~~ Not entirely sure what I have missed or added without knowing. I need a small touch of advice to help me along. Mitchell.
3 Respostas
+ 3
Mitchell Hannemann
#include <iostream>
using namespace std;
int main() {
int age = 18;
if(age > 14){
if(age >= 18){
cout<<"Adult";
}
else{
cout<<"Teenager";
}
}
else{
cout<<"child";
}
return 0;
}
+ 2
Give the code, we can understand more better.
+ 1
#include <iostream>
using namespace std;
int main()
int age = 18
if (age > 14) {
if (age >= 18) {
cout << "Adult";
}
else {
cout << "Teenager";
}
else {
if (age > 0) {
cout << "Child";
}
else {
cout << "Somethings Wrong";
}
return 0;
}