Q.1 Write a C program to declare book structure (bookno, bookname, author). Accept details of n books and display books of particular author.

 

#include<stdio.h>

#include<string.h>

struct book

{

char book_name[30];

char author[30];

int book_id;

};

int main()

{

struct book b[100]; // Here b is a variable of structure book

int i,n;

char temp[30];

printf("Welcome to DataFlair tutorials!\n\n");

printf("How many the record of  books:\n");

scanf("%d",&n);

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

{

printf("Enter the book name: ");

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

printf("Enter the author name: ");

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

printf("Enter the book ID: ");

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

}

printf("\nThe details of the book are:\n\n");

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

{

printf("The book name is: ");

puts(b[i].book_name);

printf("The author name is: ");

puts(b[i].author);

printf("The book ID is: %d\n",b[i].book_id);

}

 printf("\nEnter Author Name: ");

scanf("%s",temp);

printf("--------------------------------------");

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

{

 if(strcmp(b[i].author,temp)==0)

    {

         printf("\n%s\n",b[i].book_name);

         }

                    }

                    

return(0);

}


Q.2  Write a C program to declare employee structure (eno, ename, salary). Accept details of n employees and display salary of particular employee.

Q.3  Write a C program to declare student structure (sno, sname, percentage). Accept details of n students and display percentage of particular student.

Comments

Popular posts from this blog

Slip 11: Write node js application that transfer a file as an attachment on web and enables browser to prompt the user to download file using express js.

Slip 7 Create a node js file named main.js for event-driven application. There should be a main loop that listens for events, and then triggers a callback function when one of those events is detected.

Slip 1(a) Write an Angular 13 application addition of two numbers using ng-init, ng-model & ng-bind. And also demonstrate ng-show, ng-disabled, ng-click directives on button component.