fork download
  1. #include <iostream>
  2. #include <iomanip>
  3. using namespace std;
  4.  
  5. //------------------------------------------------------------------------------
  6.  
  7. int main()
  8. {
  9. int score1; // To hold three test scores
  10. int score2;
  11. int score3;
  12. double average; // To hold the average score
  13.  
  14. // Get the three test scores.
  15. cout << "Enter 3 test scores and I will average them: ";
  16. cin >> score1 >> score2 >> score3;
  17.  
  18. // Calculate and display the average score.
  19. average = (score1 + score2 + score3) / 3.0;
  20. cout << fixed << showpoint << setprecision(1);
  21. cout << "Your average is " << average << endl;
  22.  
  23. // Follow up with a message.
  24. if (average = 100);
  25. cout << "Congratulations! Those are all perfect scores" << endl;
  26. else
  27. cout << "Not perfect yet - Better luck next time." << endl;
  28.  
  29. cout << endl;
  30.  
  31. return 0;
  32. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'int main()':
prog.cpp:26:4: error: 'else' without a previous 'if'
    else
    ^
stdout
Standard output is empty