#include <iostream>
usingnamespace std;
struct Student{
char Firstname[20];
char Lastname[20];
int grades[4];
double average;
int i, k, n;
void calgradeaverage(void);
};
void Student::calgradeaverage(void)
{
average = 0;
shortunsignedint index;
for(index=0; index<4; index++){
average+=grades[index];
}
average /= 4;
cout<<average<<endl;
}
int main(void)
{
struct Student me ={"keith","lin",10,20,30,40};
}
well as you see i am hard coding the name and test scores. How to make the user input it? I'm not just asking letting the user input the name and stuff i want the user to be able to input the numbers of objects too.
e.g
how many object you need?
user input: 4
what's your first name?
user input: bla
what's your last name?
user input: bla
what's your first grades score?
user input: bla
what's your second grades score?
user input: bla
what's your third grades score?
user input:bla
what's your fourth grades score?
user input:bla
times four. (it means the asking ur first name last name and test scores times four since the i.e user input for the number of object is 4)