This is my assignment:

Step 1.Create a structure with the name StudentRecord containing a Name stored as an array of 20 characters, an ID stored as an integer, and a GPA stored as a floating integer. Create (instantiate) a variable from StudentRecord called TESCStudent.

Step 2. Assign the following values to the variable by assuming Name is SuperProgrammer, with an ID of 1234, and a GPA of 4.0.

Step 3. The program should print out on the screen that SuperProgrammer with an Identification number of 1234 has a 4.0 GPA. (Of course, your program needs to use the structure you defined in step 2.)

Step 4. Generalize the program so that you can input the student's name, ID, and GPA when the program is run. Please do not forget to include prompt

**********************************************

This is my code:

# include <iostream>
using namespace std;


//This program will print out a student's name, ID and GPA //


struct StudentRecord{
int ID; // student ID //
float GPA; // student's GPA //
char Name[20]; //array containing 20 characters //


};


int main()
{
StudentRecord TESCStudent; // variable of new type StudentRecord //



cout << "\nEnter student's name: ";
cin >> TESCStudent.Name;


cout << "\nEnter student's ID: ";
cin >> TESCStudent.ID;


cout << "\nEnter student's GPA: ";
cin >> TESCStudent.GPA;


cout <<TESCStudent.Name << " with an identification number of "
<< TESCStudent.ID << " has a "
<< TESCStudent.GPA << " GPA.\n";



return 0;


}
***********************************************

Can someone tell me if its correct?

Akisha

Seems Fine...
next time use code tags

Thank you for the verification.

Can someone tell me if its correct?

why do you need someone to tell you that? You can do it yourself just by running the program. Does it do what it is supposed to do? Yes, then it is correct. No, then you need to rewrite parts of it.

// variable of new type StudentRecord //

->

// variable of new type StudentRecord

You don't need //'s at the end of your single-line comments. Single-line comments terminate at a newline.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.