structure program in c

#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;
}

Comments

One response to “structure program in c”

  1. […] WRITE A PROGRAM THAT CREATE STRUCTURE BOOK WITH ID ,NAME,PRICE,PUBLICATION. […]

Leave a Reply

Your email address will not be published. Required fields are marked *