fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. char getGrade(int score) {
  5. if (score >=80) return 'A';
  6. if (score >=70) return 'B';
  7. if (score >=60) return 'C';
  8. if (score >=50) return 'D';
  9. else return 'F';
  10.  
  11. }
  12.  
  13. int main(){
  14. int score;
  15. char grade;
  16.  
  17. cout <<"กรอกคะแนนนักเรียน:";
  18. cin >> score;
  19.  
  20. grade = getGrade(score);
  21. cout << "เกรด" << grade << endl;
  22.  
  23. return 0;
  24. }
Success #stdin #stdout 0.04s 25748KB
stdin
Standard input is empty
stdout
#include <iostream>
using namespace std;

char getGrade(int score) {
    if (score >=80) return 'A';
    if (score >=70) return 'B';
    if (score >=60) return 'C';
    if (score >=50) return 'D';
    else return 'F';

}

int main(){
    int score;
    char grade;

    cout <<"กรอกคะแนนนักเรียน:";
    cin >> score;

    grade = getGrade(score);
    cout << "เกรด" << grade << endl;

    return 0;
}