Store information of Books using function with structure

Write a program to store information of Books (id, name, title and subject) using function with structure.


Source Code:

#include<stdio.h>
#include<conio.h>
struct books
{
	char t[20],n[20],s[20];
	int b,i;
};
void book(struct books st);

void main()
{
	struct books st;
	clrscr();
	printf("Enter the Book Title:");
	scanf("%s",&st.t);
	printf("Enter the Book Name:");
	scanf("%s",&st.n);
	printf("Enter the Book Subject:\n");
	scanf("%s",&st.s);
	flushall();
	printf("Enter the Book Id:");
	scanf("%d",&st.i);
	book(st);
	getch();
}



void book(struct books st)
{
	printf(" \n Book Title is =%s \n",st.t);
	printf("Book Name is =%s \n",st.n);
	printf("Book Subject is =%s \n",st.s);
	printf("Book Id is =%d  \n",st.i);
}

Output:

Enter the Book Title: Next Programming in C Language
Enter the Book Name: Next Programming in C Language
Enter the Book Subject: C Language
Enter the Book Id: 100

Book Title is = Next Programming in C Language
Book Name is = Next Programming in C Language
Book Subject is = C Language
Book Id is = 100

Leave a Reply

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