+ 1

Can someone debugg my code because am being told its needed

You are making an app to control the entrance to a club. Only clients who are 16 and above are allowed to enter. Take the age of the client as input, then output " Welcome" incase it's greater or equal to 16 and "Not Allowed" if it's not I.e if the user enters 28 as their age, the output should be "welcome". Output should be with a capital starting letter.

26th Dec 2022, 8:43 AM
Alex Boso Nzaphila
Alex Boso Nzaphila - avatar
5 Answers
+ 2
#include <iostream> using namespace std; int main() { //your code goes here int age=18; cin>>age; if (age>=16){ cout<<"Welcome"; } else{ cout<<"Not allowed"; } } This is how it should look like, you can compare to the old one and see whats wrong
26th Dec 2022, 2:23 PM
MARIOS MANOUSAKIS
MARIOS MANOUSAKIS - avatar
+ 1
#include <iostream> using namespace std; int main() { //your code goes here int age==18; // it's error statement. Just put int age ; as declaration. You can assign also when you need like int age = 18; // use = (assignment operator) , not the ==. (comparison operator) cin>>age if (age>=16); // don't put semicolon ; after if condition. [ // use { } for block initialization. [ ] are used for indexing.. cout<<"Welcome";] // here also remove ] else[ // here also remove [ cout<<"Not allowed"; ] // remove these and put } } instead.. ]
26th Dec 2022, 8:54 AM
Jayakrishna 🇼🇳
0
#include <iostream> using namespace std; int main() { //your code goes here int age==18; cin>>age if (age>=16); [ cout<<"Welcome";] else[ cout<<"Not allowed"; ] ]
26th Dec 2022, 8:46 AM
Alex Boso Nzaphila
Alex Boso Nzaphila - avatar
0
That's the code
26th Dec 2022, 8:47 AM
Alex Boso Nzaphila
Alex Boso Nzaphila - avatar
0
Let me try
26th Dec 2022, 8:57 AM
Alex Boso Nzaphila
Alex Boso Nzaphila - avatar