14,975,219 members
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?
Posted
Updated 21-Sep-10 11:17am
v2
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.

## Solution 1

Quote "I am having trouble passing the structure by reference"
```struct mystruct realstruct;
// fill the struct contents
functioncall(&realstruct);```

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

Well it depends on what problem you are trying to solve.
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.

## Solution 3

I have not got ur question completely ,

1. Passing a struct by ref :

if u have a struct say:
C#
```struct subjectsMarks
{
int Sub1;
int Sub2;
};

void func(subjectsMarks* obj)
{
}

main()
{
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.
v2
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?

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.

## Solution 4

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.