Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- struct node
- {
- int id;
- double id1;
- struct node *next;
- }*start=NULL,*current;
- void create(int a,double b)
- {
- int n,i;
- struct node *new_node;
- new_node=(struct node*)malloc(sizeof(struct node));
- new_node->next=NULL;
- if(start==NULL)
- {
- new_node->id=a;
- new_node->id1=b;
- start=new_node;
- current=new_node;
- }
- else
- {
- new_node->id=a;
- new_node->id1=b;
- current->next=new_node;
- current=new_node;
- }
- }
- void display()
- {
- struct node *c;
- c=start;
- while(c!=NULL)
- {
- printf(" {%d , %.2lf } ",c->id,c->id1);
- c=c->next;
- }
- printf("NULL\n");
- }
- int main()
- {
- create(3,2.7);
- create(5,3.7);
- create(7,2.9);
- display();
- }
Advertisement
Add Comment
Please, Sign In to add comment