Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- typedef struct chanda
- {
- int itemid;
- float price;
- struct chanda *next;
- }chanda;
- chanda *head=NULL;
- void insert_at_end()
- {
- chanda *N=(chanda*)malloc(sizeof(chanda));
- scanf("%d", &N->itemid);
- scanf("%f", &N->price);
- N->next=NULL;
- chanda *list=head;
- if(head==NULL)
- {
- head=N;
- return;
- }
- else
- {
- list->next=N;
- list=N;
- }
- }
- void display()
- {
- chanda *list;
- while(list!=NULL)
- {
- printf("ID: %d\n", list->itemid);
- printf("Price: %f\n", list->price);
- list=list->next;
- }
- }
- int main()
- {
- int i;
- for(i=0; i<2; i++)
- {
- insert_at_end();
- display();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement