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 node{
- char name[20];
- float mark;
- struct node *next;
- };
- struct node *addnode(char name[], float mark);
- int main(void){
- int j = 0;
- char StdName[10];
- float StdMarks;
- struct node *head = NULL;
- struct node *curr = NULL;
- head = curr = addnode("\0",0.0);
- for(j=0; j<3; j++){
- printf("\nEnter StdName >>");
- scanf("%s", StdName);
- printf("\nMarks for %s >>", StdName);
- scanf("%f", &StdMarks);
- curr->next = addnode(StdName, StdMarks);
- curr = curr->next;
- }
- curr = head -> next;
- j = 0;
- printf("\nnode\tName\tMarks");
- while(curr){
- printf("\n%d\t%s\t%5.2f", j++, curr->name, curr->mark);
- curr=curr->next;
- }
- return 0;
- }
- struct node *addnode(char name[], float mark){
- struct node *temp;
- temp=(struct node*)malloc(sizeof(struct node));
- strcpy(temp->name,name);
- temp->mark=mark;
- temp->next=NULL;
- return (temp);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement