Assignment 11
Assignment 11
Q1. Write a program to store 10 books issued and available in a library. Store Book name, Book
reference number, student issued roll number, department.
Ans. #include<string.h>
struct library{
char Book[10];
int ref;
int Roll;
char dept[10];
}lib[10];
int main(){
for(int i=0;i<10;i++){
scanf("%s%d%d%s",&lib[i].Book,&lib[i].Ref,&lib[i].Roll,&lib[i].dept);
printf("\n");
for(int j=0;j<10;j++){
printf("%s\t\t%d\t\t%d\t\t%s\n",lib[j].Book,lib[j].Ref,lib[j].Roll,lib[j].dept);
return 0;
Output:
1122
23109006
me
2233
23109005
me
3344
23103003
che
4455
23101008
cse
5566
23104090
ece
6677
23109008
me
7788
23106009
ice
8899
23104008
che
Enter the details Book 9:geography
9999
23102002
ce
1000
23109080
me
Q2. Write a program to calculate the difference between two time periods using structures.
Ans.
#include <stdio.h>
struct Time {
int hours;
int minutes;
int seconds;
};
struct Time calculateTimeDifference(struct Time t1, struct Time t2) {
totalSeconds %= 3600;
return diff;
int main() {
Output:
10
40
20
50
Q3. Write a program to make a simple linked list which stores the marks of students.
Ans.
#include <stdio.h>
#include <stdlib.h>
struct Student {
float marks;
};
int main() {
student1->marks = 80.60;
student1->next = NULL;
head = student1;
printf("Student 1 marks: %.2f\n", head->marks);
free(student1);
return 0;
Output: