CS102 students loves to read the book of pscp but they are facing difficulties in searching the book
in library, as the book are placed by related fields in library not by course name so it is hard to
search the book manually, the solution of this problem is suggested to have such “search program”
that takes the isbn number of book find whether the book is available or not and tells Its edition,
price , Write a search program that search the availability of book its Edition ,ISBN and price .
Hints:
1. Consider the following table for example
Code:
#include<stdio.h>
main()
{
// Variable declaration//
char flag;
int i;
char temp;
char arr[100];
int edition[]={4,3,4,5,4,6,2,3,2,1};
int isbn[]={125456112,611212545,112125456,234456662,587456952,357895751,7591593268,456852159,159357847,478521369};
float price[]={125.00,25.35,45.12,5.65,3.65,124.20,546.50,225.35,25.10,1.25};
/*Input*/
printf("Enter Book ISBN:");
scanf("%d",&i);
/* actual Working */
if (i==isbn[0]) //here I compare input number with isbn array index zero position
{
printf("Book is availaible\n");
printf("Edition:%d\n",edition[0]);
printf("Price:$%.2f",price[0]);
}
else if (i==isbn[1]) //Here i do same as which i do upside and I do it until isbn array size index 9
{
printf("Book is availaible\n");
printf("Edition:%d\n",edition[1]);
printf("Price:$%.2f",price[1]);
}
else if (i==isbn[2])
{
printf("Book is availaible\n");
printf("Edition:%d\n",edition[2]);
printf("Price:$%.2f",price[2]);
}
else if (i==isbn[3])
{
printf("Book is availaible\n");
printf("Edition:%d\n",edition[3]);
printf("Price:$%.2f",price[3]);
}
else if (i==isbn[4])
{
printf("Book is availaible\n");
printf("Edition:%d\n",edition[4]);
printf("Price:$%.2f",price[4]);
}
else if (i==isbn[5])
{
printf("Book is availaible\n");
printf("Edition:%d\n",edition[5]);
printf("Price:$%.2f",price[5]);
}
else if (i==isbn[6])
{
printf("Book is availaible\n");
printf("Edition:%d\n",edition[6]);
printf("Price:$%.2f",price[6]);
}
else if (i==isbn[7])
{
printf("Book is availaible\n");
printf("Edition:%d\n",edition[7]);
printf("Price:$%.2f",price[7]);
}
else if (i==isbn[8])
{
printf("Book is availaible\n");
printf("Edition:%d\n",edition[8]);
printf("Price:$%.2f",price[8]);
}
else if (i==isbn[9])
{
printf("Book is availaible\n");
printf("Edition:%d\n",edition[9]);
printf("Price:$%.2f",price[9]);
}
else //if i not match with any isbn array index
{
printf("Not found");
}
return 0;
}
Sample Input: Book ISBN: 478521369
Sample Output: Book is available
Edition: 1
Price:$1.25
Program Output:
For more problems click here
No comments:
Post a Comment