Student Struct Passing to an Array

Write a program that inputs students’ names followed by their test scores. The program should output each student’s name followed by their scores and grades. Student data should be scored in a struct variable of type studentType, which has 4 components: studentFname and studentLname of type string, testScore of type int (0..100) and grade of type char. Suppose that the class has 20 students. Use an array of 20 components of studentType.
Your program should contain the following functions:

a. A function to input the students’ data into an array
b. A function to assign the relevant grade to each student
c. A function to display on screen the name, score and grade.

Now I Have Got this so far
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# include <iostream>
using namespace std;
// structure to Store Student Records

int i =0;
struct studentType {
       char studentFname;               // student FirstName
       char studentLname;              // Student LastName
       int testScore;                    // between 0 & 100 
       char grade;                       // Letter Value Of Grade Such AS P,C,D,HD
       };
int main()
 {
 cin <<studentFname<<studentLname<testScore<<grade;
   
   cout >>studentType;
         system ("pause");
         return 0 ;


I know the CIN Statement is wrong

though i am not sure of how to achieve the passing of the data to the array by importing it into the format of the struct or how to fill the empty structure and pass this through to an array as i thought the array could only store a single datatype

I was thinking for the Array input using for for loop to input while the number of records is less than 21 to store the 20 elements

I Can define an array fine but have yet to be able to sequentially add data

any help on how to achieve this would be greatly appreciated

Thanks
refer here: http://www.cplusplus.com/doc/tutorial/structures/

though i am not sure of how to achieve the passing of the data to the array by importing it into the format of the struct or how to fill the empty structure and pass this through to an array as i thought the array could only store a single datatype

you're thinking too far, try to do this in a simpler manner, e.g do it with 2 or 3 instances of your struct in main, then generalize it with a function, then do it with an array. Good luck.
Thanks i will give it a go if i have any questions i will post them
Topic archived. No new replies allowed.