Create a structre of Books with Book title,Author name,Publication and Price and Display all Book Records - C - A6P3



/* Write a program to create a structre of Books with Book title,Author name,Publication and Price and
    Display all Book Records  */


#include<stdio.h>
#include<conio.h>
struct books
{
    char title[100];
    char author[100];
    char pub[100];
    float price;
};
struct books bk[3];
void print();
void main()
{
    int a;
    clrscr();
    for(a=0;a<3;a++)
    {
        printf("\n:: Enter Detail of Book %d :: \n",a+1);
        printf("Enter Book Title -> ");
        fflush(stdin);
        gets(bk[a].title);
        printf("Enter Author -> ");
        gets(bk[a].author);
        printf("Enter Publication -> ");
        gets(bk[a].pub);
        printf("Enter Price -> ");
        scanf("%f",&bk[a].price);
    }
    print();
    getch();
}
void print()
{
    int a;
    printf("\n\t::: Book Details :::\n\n");
    for(a=0;a<3;a++)
    {
        printf("\nTitle       -> %s",bk[a].title);
        printf("\nAuthor      -> %s",bk[a].author);
        printf("\nPublication -> %s",bk[a].pub);
        printf("\nPrice       -> %.2f \n",bk[a].price);
    }
}
float *ab(float *a)
{
    return a;
}

Post a Comment