Click here to Skip to main content
15,845,744 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am working on a grading program and I am having trouble passing the structure by reference and by pointer. I am also trying to convert the total numeric average into a letter grade? Should I use a loop or an array to determine the letter grade?
Updated 21-Sep-10 12:17pm
AspDotNetDev 21-Sep-10 17:11pm    
Post some code. Also, it is not clear what you mean by "should I use a loop or a struct". Clarify that.
PrOwr!+3r 21-Sep-10 17:44pm    
I meant an array not the struct to calculate the letter grade.

Quote "I am having trouble passing the structure by reference"
struct mystruct realstruct;
// fill the struct contents

Quote " Should I use a loop or a struct?"

Well it depends on what problem you are trying to solve.
Share this answer
PrOwr!+3r 21-Sep-10 17:36pm    
Reason for my vote of 5
Automatic vote of 5 for accepting answer.
PrOwr!+3r 21-Sep-10 17:39pm    
what about by pointer? i was thinking of using a loop, a switch or an array to convert the number average into a letter grade. I am out of practice.
I have not got ur question completely ,

1. Passing a struct by ref :

if u have a struct say:
struct subjectsMarks
 int Sub1;
 int Sub2;

void func(subjectsMarks* obj)

  subjectsMarks* p = new subjectsMarks;
  p->sub1 = 100;
  p->sub2 = 200;
  func(subjectsMarks); //pass it here as a ref

I have not compiled it, but just this might give a rough idea about passing it as a ref.

2. Even if you will use a array, u need to loop & get the average.

Give some snapshot so that we can have a rough idea.
Share this answer
ThatsAlok 22-Sep-10 2:51am    
It seems you passing it by pointer
Sandeep Mewara 22-Sep-10 5:18am    
PRE tags?
Emilio Garavaglia 22-Sep-10 6:10am    
Why teaching people "how to create memory leaks" without telling them?
ganeshkawade2003 22-Sep-10 11:08am    
Im sry i was just giving him some insight on passing a structure pointer as an argument, never thought he'd b using the same code.
Well , Ofcourse of Emilio's comment ,

plz dont forget to add a delete subjectsMarks in ur code.

Im sry i was just giving him some insight on passing a structure pointer as an argument.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900