Define a structure called Class with the following data:
title (class title), units (number of units) and grade (letter grade received for the class).
Define a structure called Student with the following data:
name (for student name - can include spaces), gpa, and classes which is an array of Class structures (all classes the student has taken.
Write a function that receives an array of Student structures and sets the gpa of all to 0.0.

i do not know how to set the gpa of all students to 0.00


#include <iostream>
#include <string>

struct Class
	{	char class_title[10];
		int units;
		char let_grade;

struct student
	{	char name[30];
		float gpa;
		Class classes[50];
void sets ([]);
int main()
	cout << "Ener student name: " << i << endl
system ("pause");
return 0;

void sets (s[])
	for (int i=0; i<=s[], i++);
	return 0;
9 Years
Discussion Span
Last Post by prushik

Declare an array of type student in main() just like you'd declare an array of type int or an array of type double.

Also change this:

void sets ([]);

to something like this:

void sets(student studentArray[], int size);

and make the appropriate changes in the definition as well. In the body of the definition of sets() use a loop ranging from 0 to less than size (where size is the number of elements in the array). In the body of the loop, access the gpa data member of each element of the array using the dot operator to assign it the value of 0.0. Remember: each element of an array is accessed using the [] operator with the appropriate index with the brackets.

Another consideration would be to declare and define your own default constructor for the student struct type and initialize the value of gpa within an initializer list to 0.0. That way all student objects created with the default constructor, such as all the student elements in the array, will have the value of 0.0 for the gpa. However, this is a more general approach and I don't think it meets the specific criteria of the problem you're supposed to solve.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.