#include <iostream>
struct Student
{
int Grade;
int StudentID;
};
void GradeInput(Student * student);
void PrintInformation(Student * student);
int main()
{
Student student[11] = { 0 }; // Create an array of structs. Each element of the array holds 2 ints: student grade and student ID.
GradeInput(student); // Pass the address of the struct to our function
PrintInformation(student); // Pass the address of the struct to our function
std::cin.get();
}
void GradeInput(Student * student) // declare a pointer that points to our Student structure
{
for (int i = 0; i < 10; i++)
{
std::cout << "Enter grade for student " << i + 1 << "." << std::endl; // i + 1 because arrays start counting at 0.
std::cin >> student[i].Grade; // Get user input for int Grade.
std::cout << "Enter ID for student " << i + 1 << "." << std::endl;
std::cin >> student[i].StudentID; // Get user input for int Student ID.
}
}
void PrintInformation(Student * student) // declare a pointer that points to our Student structure
{
for (int i = 0; i < 10; i++)
{
std::cout << "Student " << i + 1 << "'s grade: " << student[i].Grade << "." << std::endl; // Output our student ID.
std::cout << "Student " << i + 1 << "'s ID: " << student[i].StudentID << "." << std::endl; // Output our student ID.
}
}
I did the first two for you. Use this as a reference to help you with 3 and 5.