Displaying a different message for A, B, C, and F grades. - C++ Statement

C++ examples for Statement:if

Description

Displaying a different message for A, B, C, and F grades.

Demo Code

#include <iostream> 
   //from  w  w w. ja v a2  s .  co  m
int main() 
{ 
    int grade; 
    std::cout << "Enter a grade (1-100): "; 
    std::cin >> grade; 
 
    if (grade >= 70) 
    { 
           if (grade >= 90) 
           { 
               std::cout << "\nYou got an A. Great job!\n"; 
               return 0; 
           } 
           if (grade >= 80) 
           { 
               std::cout << "\nYou got a B. Good work!\n"; 
               return 0; 
           } 
           std::cout << "\nYou got a C. Perfectly adequate!\n"; 
    } 
    else 
           std::cout << "\nYou got an F. I failed as a parent!\n"; 
  
    return 0; 
}

Result


Related Tutorials