Originally Posted by
laserlight
A name would be a string, so it would not be a single char. The fees should use fixed point rather than floating point, so one approach is to store the quantity in cents instead of dollars (or whatever are the corresponding currency terms used in your country).
You would presumably use dynamic memory allocation to store the lists of students and classes.
Thank you laserlight and salem
okay So I made a list just to store student fees.
Code:
#include<stdio.h>#include<stdlib.h>
struct node{
int Fees;
struct node *next;
};
struct node* newNode(int college_fees, struct node *next) {
struct node *new = malloc(sizeof(*new));
new->Fees = college_fees;
new->next = next;
return new;
}
void show(struct node *head){
struct node *c;
c = head;
while (c!=NULL){
printf("%d dollar \n",c->Fees);
c = c->next;
}
}
int main (void ) {
struct node *head = NULL;
head = newNode(10, head);
head = newNode(20, head);
head = newNode(30, head);
head = newNode(40, head);
head = newNode(50, head);
head = newNode(60, head);
show(head);
return 0;
}
60 dollar
50 dollar
40 dollar
30 dollar
20 dollar
10 dollar
why did you suggested dynamic memory allocation to store the lists of students and classes. instead of fixed size array?