- 3

Y have error for test 3, 4 and i don't know for why?

Admission to the pool is free for children under 7 years of age. The given program takes age as an input. Task Complete the code to output "free" if the child's age is less than 7. Sample Input 6 Sample Output free

20th Sep 2021, 8:21 PM
Mona Alidi
Mona Alidi - avatar
7 Answers
+ 1
You are comparing the input age to itself age. This will produce "free" for any input. if (age<=6){cout<<"free"<<endl;} else if (age>6){cout<< ""<<endl;} Now comparing to 6.
20th Sep 2021, 9:30 PM
Magne
Magne - avatar
0
My code : #include <iostream> using namespace std; int main() { int age; cin >> age; // your code goes here if (age<=age){cout<<"free"<<endl; } else if (age>age){cout<< ""<<endl;} return 0; }
20th Sep 2021, 8:45 PM
Mona Alidi
Mona Alidi - avatar
0
Thank's
20th Sep 2021, 9:54 PM
Mona Alidi
Mona Alidi - avatar
0
#include <iostream> int main() { int age; std::cin >> age; // your code goes here if (age <= 7){ std::cout << "free"; } else if (age > 7){ std::cout << ""; } return 0; } // FZ
31st Dec 2021, 12:59 AM
Fabian Zelaya
Fabian Zelaya - avatar
0
#include <iostream> using namespace std; int main() { int age; cin >> age; // your code goes here if (age<=7){cout<<"free"<<endl; } else if (age>7){cout<< ""<<endl;} return 0; } Good Luck
25th Jan 2022, 11:09 AM
Muhammad Alif Deva Rizqon
Muhammad Alif Deva Rizqon - avatar
0
#include <iostream> int main() { int age; std::cin >> age; // your code goes here if (age <= 7){ std::cout << "free"; } else if (age > 7){ std::cout << ""; } return 0; } //AHS
10th May 2022, 9:21 PM
Abdoulaye Hamadoun SAKAYE
- 1
int age; cin >> age; // your code goes here if (age <= 7){ cout<<"free"; }else if (age > 7){ cout<<""; } this one works
5th Dec 2021, 3:53 PM
kleiber PĂ©rez Montero
kleiber PĂ©rez Montero - avatar