forked from MadhavBahl/OOPS
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstruct.c
More file actions
46 lines (38 loc) · 1.17 KB
/
struct.c
File metadata and controls
46 lines (38 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/* =========================== */
/* ===== Structures in C ===== */
/* =========================== */
#include<stdio.h>
#include<string.h>
struct Books {
char title[50];
char author[50];
char subject[100];
int book_id;
};
int main() {
// Declare 2 instances of structure books
struct Books book1,book2;
// Enter the details of both books
printf("Enter the title of book 1: ");
gets(book1.title);
printf("Enter the author of book 1: ");
gets(book1.author);
printf("Enter the subject of book 1: ");
gets(book1.subject);
book1.book_id = 10293;
printf("Enter the title of book 2: ");
gets(book2.title);
printf("Enter the author of book 2: ");
gets(book2.author);
printf("Enter the subject of book 2: ");
gets(book2.subject);
book2.book_id = 10341;
// Print the details of both books
printf("\nTitle of book 1: %s",book1.title);
printf("\nAuthor of book 1: %s",book1.author);
printf("\nSubject of book 1: %s",book1.subject);
printf("\nTitle of book 2: %s",book2.title);
printf("\nAuthor of book 2: %s",book2.author);
printf("\nSubject of book 2: %s",book2.subject);
return 0;
}