Write the program that ask user insert 5 type integers of an array for student number for each course(MECHA : 280, IART : 150, HVAC : 200, FJ : 180, ASMT : 150) program must calculate the total student & percentage each course

I would use C++ to create an 'array of structs'; each struct should contain attributes for class name and for class number. Then create an array of appropriate size of the aforementioned struct object. Populate the array by prompting for user input.

I would use C++ to create an 'array of structs'; each struct should contain attributes for class name and for class number. Then create an array of appropriate size of the aforementioned struct object. Populate the array by prompting for user input.

can you give example for this?????

Here I wrote a pretty good example of how to use an 'array of structs.' This data structure should be one of those go-to items in your bag of tricks as a CS student because so many times you will be tasked with creating some sort of database of information (bank accounts, hotel records, phone books, airline tickets.. the list goes on.)

Just as a hint, I would design your struct like this:

struct flights{

     string flight_name;
     int flight_number;   
};

Now that you have designed your object, you just have to create a whole bunch of them:

flight flight_records[100];

Now all you have to do is populate your 'array of flights' by prompting for user input.

Get down with the 'array of structs' and use it frequently throughout your CS academic career.

Edited 7 Years Ago by Clinton Portis: n/a

This article has been dead for over six months. Start a new discussion instead.