Computer Science, asked by shahensha823, 2 months ago

Q. Using structure, write a program about books with the following information:

Name, author, publisher and year.​

Answers

Answered by nattkudrat
1

#include<stdio.h>

#include<conio.h>

#include<string.h>

#define SIZE 20

struct bookdetail

{

char name[20];

char author[20];

int pages;

float price;

};

void output(struct bookdetail v[],int n);

void main()

{

struct bookdetail b[SIZE];

int n,i;

clrscr();

printf("Enter the Numbers of Books:");

scanf("%d",&n);

printf("\n");

for(i=0;i<n;i++)

{

printf("\t=:Book %d Detail:=\n",i+1);

printf("\nEnter the Book Name:\n");

scanf("%s",b[i].name);

printf("Enter the Author of Book:\n");

scanf("%s",b[i].author);

printf("Enter the Pages of Book:\n");

scanf("%d",&b[i].pages);

printf("Enter the Price of Book:\n");

scanf("%f",&b[i].price);

}

output(b,n);

getch();

}

void output(struct bookdetail v[],int n)

{

int i,t=1;

for(i=0;i<n;i++,t++)

{

printf("\n");

printf("Book No.%d\n",t);

printf("\t\tBook %d Name is=%s \n",t,v[i].name);

printf("\t\tBook %d Author is=%s \n",t,v[i].author);

printf("\t\tBook %d Pages is=%d \n",t,v[i].pages);

printf("\t\tBook %d Price is=%f \n",t,v[i].price);

printf("\n");

}

}

Output:

Enter The Numbers of Books:3

=:Book 1 Detail:=

Enter the Book Name:

letusc

Enter the Author of Book:

Y.Kanetkar

Enter the Pages of Book:

850

Enter the Price of Book:

160

=:Book 2 Detail:=

Enter the Book Name:

IC

Enter the Author of Book:

Peter

Enter the Pages of Book:

200

Enter the Price of Book:

70

=:Book 3 Detail:=

Enter the Book Name:

ANSIC

Enter the Author of Book:

Balaguruswami

Enter the Pages of Book:

450

Enter the Price of Book:

100

Book No.1

Book 1 Name is=Letusc

Book 1 Author is=Y.Kanetkar

Book 1 Pages is =850

Book 1 Price is =160.000000

Book No.2

Book 2 Name is=IC

Book 2 Author is=Peter

Book 2 Pages is=200

Book 2 Price is =70.000000

Book No.3

Book 3 Name is=ANSIC

Book 3 Author is=Balaguruswami

Book 3 Pages is=450

Book 3 Price is=100.000000

Follow me!

Hope it helps you in understanding!

Mark me as brainliest answer!

Thank me if you like it!

Similar questions