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 prize;
- struct node *next;
- }*start=NULL;
- void cre()
- {
- struct node *c,*n;
- int a,i;
- printf("Enter book number:\n");
- scanf("%d",&a);
- for(i=0;i<a;i++)
- {
- n=(struct node*)malloc(sizeof(struct node));
- printf("Enter book id:\n");
- scanf("%d",&n->id);
- printf("Enter book prize\n");
- scanf("%lf",&n->prize);
- n->next=NULL;
- if(start == NULL)
- {
- start=n;
- c=n;
- }
- else
- {
- c->next = n;
- c=n;
- }
- }
- }
- void dis()
- {
- struct node *c;
- c=start;
- while(c!=NULL)
- {
- printf("Id-->%d-->%.1lf-->",c->id,c->prize);
- c=c->next;
- }
- printf("NULL");
- }
- void max()
- {
- struct node *c;
- c=start;
- double max=0;
- while(c!=NULL)
- {
- if(max<c->prize)
- {
- max=c->prize;
- }
- c=c->next;
- }
- printf("\nHighest prize is %.1lf\n",max);
- }
- int main()
- {
- cre();
- dis();
- max();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement