Repository navigation
Expand file tree
/
Copy pathPrice.c
More file actions
76 lines (57 loc) · 1.42 KB
/
Copy pathPrice.c
File metadata and controls
76 lines (57 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include<stdio.h>
struct Book{
char title[100];
char author[100];
float price;
} ;
int main(){
struct Book book1,book2,book3;
printf("Input details for book 1:\n");
printf("Title:");
scanf("%s",book1.title);
printf("Author:");
scanf("%s",book1.author);
printf("Price:");
scanf("%f",&book1.price);
printf("Input details for book 2:\n");
printf("Title:");
scanf("%s",book2.title);
printf("Author:");
scanf("%s",book2.author);
printf("Price:");
scanf("%f",&book2.price);
printf("Input details for book 3:\n");
printf("Title:");
scanf("%s",book3.title);
printf("Author:");
scanf("%s",book3.author);
printf("Price:");
scanf("%f",&book3.price);
struct Book mostExpensive;
if(book1.price>=book2.price && book1.price>=book3.price){
mostExpensive=book1;
}else if (book2.price>=book1.price && book2.price>=book3.price){
mostExpensive=book2;
}
else{
mostExpensive=book3;
}
struct Book lowestPriced;
if(book1.price<=book2.price && book1.price<=book3.price){
lowestPriced=book1;
}else if (book2.price<=book1.price && book2.price<=book3.price){
lowestPriced=book2;
}
else{
lowestPriced=book3;
}
printf("Most Expensive book:\n");
printf("Title:%s\n",mostExpensive.title);
printf("Author:%s\n",mostExpensive.author);
printf("Author:%2f\n",mostExpensive.price);
printf("Lowest Priced book:\n");
printf("Title:%s\n",lowestPriced.title);
printf("Author:%s\n",lowestPriced.author);
printf("Author:%2f\n",lowestPriced.price);
return 0;
}