#include<stdio.h>
#include<string.h>
struct book
{
int id,price;
char name[20],pub[20];
};
int main()
{
int i;
struct book b[5];
for(i=0;i<5;i++)
{
printf("\n Book ID?");
scanf("%d",&b[i].id);
printf("\n Book Name?");
scanf("%s",b[i].name);
printf("\n Book Publication?");
scanf("%s",b[i].pub);
printf("\n Book price?");
scanf("%d",&b[i].price);
}
printf("\n =====> Book Information <======");
for(i=0;i<5;i++)
{
printf("\n %d \t %s \t %s \t %d",b[i].id,b[i].name,b[i].pub,b[i].price);
}
printf("\n =====> Book Information(BPB and price < 300) <======");
for(i=0;i<5;i++)
{
if(b[i].price < 300)
{
if(strcmp(b[i].pub,"BPB")==0)
{
printf("\n %d \t %s \t %s \t %d",b[i].id,b[i].name,b[i].pub,b[i].price);
}
}
}
return 0;
}
structure program in c
Comments
One response to “structure program in c”
-
[…] WRITE A PROGRAM THAT CREATE STRUCTURE BOOK WITH ID ,NAME,PRICE,PUBLICATION. […]
Leave a Reply