# Hi some questions

• 01-22-2012
student111
Hi some questions
Hi,

I have some questions about a program in which we calculate a GPA(Grade Point Average).

Eg.

formula:
GPA = Grade Point + Credit Hours;

My program is :

Code:

```class student { public: student(int Grade_Point,int Credit_Hour); //initializing the data members of the class using constructor/ ~student(); // destructor of the class/ void GetData(); void CalculateGPA(); void WriteData(); private: int Grade_Point; int Credit_Hour ; GPA = Grade Point + Credit Hours; // formula used for calculating GPA(Grade Point Average)/ }; int main() { cout<<"Student GPA"; int Grade_Point; int Credit_Hour; int GPA; system("pause"); }```
-----------------------------------------------
I wanted to know that can I declare arrays for GP and Credit Hours,so that they could be used in the formula for GPA calculation?

Also pls let me know if I have correctly initalized the data members of the class using the constructor.

My other question is that do I have to use "int" before main()?

I hope I am clear
• 01-22-2012
jimblumberg
Quote:

I wanted to know that can I declare arrays for GP and Credit Hours,so that they could be used in the formula for GPA calculation?
Yes you can create arrays to hold the GP and Credit Hours and still use these variables in your calculation.
Quote:

Also pls let me know if I have correctly initalized the data members of the class using the constructor.
Since you did not post the class implementation, I would say probably not.

Quote:

My other question is that do I have to use "int" before main()?
Yes, and you should return an int from this function, usually zero.

Also you GPA calculation looks incorrect. How do you determine a Grade Point? How do you determine an average?

Jim
• 01-22-2012
whiteflags
I always thought that grade point average was actually a quotient and not a sum, but that's just one of my crazy ideas.
• 01-22-2012
student111
Hi,

If I also use "char" as a data type for any of these data members then still can I use "int" before the main()?

Is "string" a data type?

The formula for calculating GPA is GPA=GradePoint * CreditHour
• 01-22-2012
jimblumberg
Quote:

If I also use "char" as a data type for any of these data members then still can I use "int" before the main()?
The function main must be defined as a function returning an int, always.

Isn't Grade Point Average an average of Grade Points? How do you compute the Grade Point? What is the definition of an Average? How do you compute an average?

Quote: