# Structure and Functions Help

Discussion in 'C' started by prockaz, Apr 12, 2012.

1. ### prockazNew Member

Joined:
Apr 12, 2012
Messages:
3
0
Trophy Points:
0
Define a structure called Pagent that stores contestant no, first and last name, country, their scores (a floating-point array that stores 5 judges score), a floating-point array stats that stores statistics such as average, highest score and lowest score.

Define a function AddPerson that will accept a pointer to an array of Pagent. The function should enter contestant details (names, country and the judges scores) into the array using pointer notation. The first contestant number begins with 200, and is incremented by 1 for each member following. The function should allow the user to add only one or more Contestant as they wish.

2. ### hobbyistNew Member

Joined:
Jan 7, 2012
Messages:
141
0
Trophy Points:
0
What part(s) are you having a problem with?

Code:
```#define INIT_PAG_NUM 200

typedef struct {
/* add vars as required */
} pagent;

void addPerson(pagent *); /* function prototype */

int main(void) {
... bits of code
}```
Based on what you've posted, the function would probably need a control loop, so that the user could enter data for as many contestants as wanted.

Code:
```void addPerson(pagent *tmp) {

loop(while user wanting to add data is true) {
/* pointer notation (tmp + current_index)->member_field */
}
}```
that loop should also check against current_index being valid for the maximum number of contestants... you don't want to add data to a record that doesn't exist even if the user insists on trying.

3. ### prockazNew Member

Joined:
Apr 12, 2012
Messages:
3
0
Trophy Points:
0
thanks man !

4. ### geethesh babuNew Member

Joined:
Apr 26, 2012
Messages:
2
0
Trophy Points:
0
k k can u tell me this programm it s immediately so..........
1) write a cprogeamm that will be the value x and evaluate the following function?
y=1 for x>0
y=0 for x=0
y=-1 for x<0

5. ### geethesh babuNew Member

Joined:
Apr 26, 2012
Messages:
2
0
Trophy Points:
0
1) write a cprogeamm that will be the value x and evaluate the following function?
y=1 for x>0
y=0 for x=0
y=-1 for x<0

6. ### hobbyistNew Member

Joined:
Jan 7, 2012
Messages:
141
```y = myfunction(x);