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