Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  Prog2
Language: C/C++
Code:
#include <stdio.h>
#include <string.h>
struct book
{
char title[50];
char publisher[50];
float date;
float price;
};

int main()
{
char c[50];
int i,k,cnt;
cnt=0;
struct book b[100];
for(i=0; i<100; i++)
{
 printf ("Title:");
 gets(b[i].title);
 printf ("publisher:");
 gets(b[i].publisher);
 printf("Date:");
 scanf("%f\n",&b[i].date);
 printf("Price:");
 scanf("%f\n",&b[i].price);
}
 printf("Which book are you looking for?");
 scanf("%c",&c[50]);
for(i=0; i<100; i++)
 {
 k=strcmp(c,b[i].title);
 if(k==0)
{
printf("T: %c P: &c D: %f P: %f",b[i].title,b[i].publisher,b[i].date,b[i].price);
}
else
{
cnt++;
}
if(cnt==100)
{
printf("Auto to bilbio den yparxei");
}
}
return 0;
}

 

Comments: