Answer to Question #325381 in C++ for Vilo

Question #325381

Write a C++ Program to Find Grade of a Student using if else. 


1
Expert's answer
2022-04-07T17:39:45-0400
#include <iostream>
using namespace std;

int main()
{
int grade;

cout << "Enter the numerical grade: ";
cin >> grade;

if (grade > 100 || grade < 0)
{
  cout << "Invalid data" << endl;
}

else
{
  cout << "The letter grade: ";
  
  if (grade > 89)
  {
  cout << "A";
  }

  else if (grade > 79)
  {
  cout << "B";
  }

  else if (grade > 69)
  {
  cout << "C";
  }

  else if (grade > 59)
  {
  cout << "D";
  }

  else
  {
  cout << "F";
  }

  cout << endl;
}

return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS