Quality Point for Numeric Grades with if statement - C++ Statement

C++ examples for Statement:if

Introduction

  • returns 4 if a student's average is 90-100,
  • 3 if the average is 80-89,
  • 2 if the average is 70-79,
  • 1 if the average is 60-69 and
  • 0 if the average is lower than 60.

Demo Code


#include <iostream>

int qualityPoint(int);

int main(int argc, const char *argv[]) {
    int average = 0;

    std::cout << "Input student average: ";
    std::cin >> average;/*ww  w. j a  v  a 2 s.co  m*/

    std::cout << "Quality Point: " << qualityPoint(average) << std::endl;

    return 0;
}
// returns int representation of a students average
int qualityPoint(int average) {
    if (average >= 90 && average <= 100) return 4;
    if (average >= 80 && average <= 89) return 3;
    if (average >= 70 && average <= 79) return 2;
    if (average >= 60 && average <= 69) return 1;

    return 0;
}

Result


Related Tutorials