Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- struct node
- {
- int id;
- double mark;
- struct node *next;
- }*start=NULL;
- void create()
- {
- int i,n;
- struct node *new_node,*current;
- printf("Enter the number of student :");
- scanf("%d",&n);
- for(i=0;i<n;i++){
- new_node=(struct node *)malloc(sizeof(struct node));
- if(new_node==NULL){
- printf("ERORE allocation\n");
- }
- printf("Enter the id of the student: ");
- scanf("%d",&new_node->id);
- printf("Enter the mark of the student: ");
- scanf("%lf",&new_node->mark);
- new_node->next=NULL;
- if(start==NULL){
- start=new_node;
- current=new_node;
- }
- else
- {
- current->next=new_node;
- current=new_node;
- }
- }
- }
- double ave()
- {
- double sum=0,ave;
- int c=0;
- struct node *current;
- current=start;
- while(current!=NULL){
- c++;
- sum=sum+current->mark;
- current=current->next;
- }
- ave=sum/(double)c;
- printf("The average quiz mark is=%0.1lf\n",ave);
- }
- void display()
- {
- struct node *current;
- current=start;
- while(current!=NULL){
- printf("id-%d-%0.1lf-->",current->id,current->mark);
- current=current->next;
- }
- printf("NULL\n");
- }
- int main()
- {
- create();
- display();
- ave();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement