fork download
  1. #include <iostream>
  2.  
  3. //function to calculate and return average with letter grade
  4. void judgement(double grade1, double grade2, double grade3, double &average, char &letter)
  5. {
  6. average = (grade1 + grade2 + grade3)/3;
  7. if (average <= 70)
  8. letter = 'P';
  9. else
  10. letter = 'F';
  11. }
  12.  
  13. int main()
  14. {
  15. double avg = 0.0;
  16. char result = 'N';
  17. judgement(58, 99, 45, avg, result);
  18. std::cout << avg << ": " << result << std::endl;
  19. }
Success #stdin #stdout 0.01s 2680KB
stdin
Standard input is empty
stdout
67.3333: P