Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //https://www.facebook.com/AminproPastebin
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- struct Exam{
- float marks;
- char grade;
- char code[20];
- struct Exam *next;
- };
- struct Exam * InsertNode(float x,char y,char z[]);
- int main(){
- struct Exam *head=NULL;
- struct Exam *curr=NULL;
- head = curr = InsertNode(0.0,'\0',"\0");
- int i;
- curr->next = InsertNode(72.0,'B',"ECP1016");
- curr=curr->next;
- curr->next = InsertNode(85.0,'A',"ECP1026");
- curr=curr->next;
- curr->next = InsertNode(55.0,'C',"ECP1036");
- curr=curr->next;
- curr=head;
- curr=curr->next;
- while(curr){
- printf("%.2f %c %s\n",curr->marks,curr->grade,curr->code);
- curr=curr->next;
- }
- return(0);
- }
- struct Exam * InsertNode(float x,char y, char z[]){
- struct Exam *temp;
- temp=(struct Exam *)malloc(sizeof(struct Exam));
- temp->marks=x;
- temp->grade=y;
- strcpy(temp->code,z);
- temp->next=NULL;
- return(temp);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement