fork download
  1. // My Bar
  2.  
  3. #include <iostream>
  4. #include <string>
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. int age; // declare variable
  10.  
  11. cout << "At this bar you have to be 21 and up to be in here ";
  12. cout << " by the way, how old are you?\n"; // Ask primary question
  13. cin >> age; // retrieve personal information
  14. cout << age << endl;
  15. cin.get();
  16.  
  17. if (age > 21)
  18. {
  19. cout << "You could've fooled me... What you're having?\n"; // allow access
  20. }
  21. else (age == 21)
  22. {
  23. cout << "You're Ok\n"; // barely allow access
  24. }
  25. else
  26. {
  27. cout << "Get the F*** out of my bar!!!\n"; // deny access
  28. }
  29. return 0;
  30. }
  31.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:22: error: expected `;' before ‘{’ token
prog.cpp:25: error: ‘else’ without a previous ‘if’
stdout
Standard output is empty