Need Help understanding arrays and pointers
Hi guys! I have this homework to do and I am not sure how to get this done, so if anyone could help it would be great.
This is what is asked:
Design and run a program that takes a numerical score and outputs a letter grade. Specific numerical scores and letter grades are listed below:
90-100 = Grade A
80-89 = Grade B
70-79 = Grade C
60-69 = Grade D
0-59 = Grade F
In this program, create 2 void functions titled getScore and printGrade with an int argument. The function getScore should have a Reference parameter and printGrade should have a Value parameter.
The function getScore will prompt the user for the numerical score, get the input from the user, and print the numerical score. The function printGrade will calculate the course grade and print the course grade. (Be careful and note that the assignment requires you to input the grade into getScore and not directly into the main function.)
This is what I did so far. It compiles without giving me any error but the output stays blank.
Code:
#include "stdafx.h"
#include <iostream>
#include <stdlib.h>
using std::cout;
using std::cin;
using std::endl;
using namespace std;
int score;
void getScore();
void printGrades();
void getScore (int&)
{
std::cout << "Please input the grade score: ";
std::cin >> score;
std::cout << "You entered the score of"<<score<<endl;
return;
}
void printGrades(int )
{
if (score >= 0 && score <= 59)
{
std::cout << "The grade is an F.";
}
else if (score >= 60 && score <= 69)
{
std::cout << "The grade is a D.";
}
else if (score >= 70 && score <= 79)
{
std::cout << "The grade is a C.";
}
else if (score >= 80 && score <= 89)
{
std::cout << "The grade is a B.";
}
else if (score >= 90 && score <= 100)
{
std::cout << "The grade is an A.";
}
return;}
int main()
{
void getScore();
void printGrades();
return 0;
}
Thanks for your help.