Repository navigation
Expand file tree
/
Copy pathstruct.c
More file actions
194 lines (150 loc) · 4.74 KB
/
Copy pathstruct.c
File metadata and controls
194 lines (150 loc) · 4.74 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
#include<stdio.h>
#include<string.h>
#include<math.h>
struct Date {
int day;
int month;
int year;
};
struct Book {
char Title[50];
char Author[50];
int Pages;
struct Date dop;
};
int main() {
// struct Book book1;
// printf("Enter the title :");
// fgets(book1.Title,50,stdin);
// printf("Enter the author :");
// fgets(book1.Author,50,stdin);
// printf("Enter the pages in book :");
// scanf("%d", &book1.Pages);
// printf("Enter the day of publish :");
// scanf("%d", &book1.dop.day);
// printf("Enter the month of publish:");
// scanf("%d", &book1.dop.month);
// printf("Enter the year of publish :");
// scanf("%d", &book1.dop.year);
// printf("\nThe tite of book : %s ", book1.Title);
// printf("\nThe Author of book : %s ", book1.Author);
// printf("\nThe no of pages in : %d ", book1.Pages);
// printf("\nThe dop of book (DD-MM-YYYY): %d-%d-%d", book1.dop.day ,book1.dop.month ,book1.dop.year);
struct Book book[10];
int n;
printf("Enter the no of books to be updated :");
scanf("%d", &n);
for(int i=0; i<n; i++) {
getchar();
printf("Enter the title :");
fgets(book[i].Title,50,stdin);
printf("Enter the author :");
fgets(book[i].Author,50,stdin);
printf("Enter the pages in book :");
scanf("%d", &book[i].Pages);
printf("Enter the day of publish :");
scanf("%d", &book[i].dop.day);
printf("Enter the month of publish:");
scanf("%d", &book[i].dop.month);
printf("Enter the year of publish :");
scanf("%d", &book[i].dop.year);
}
for(int i=0; i<n; i++) {
printf("The tite of book : %s \n", book[i].Title);
printf("The Author of book : %s \n", book[i].Author);
printf("The no of pages in : %d \n", book[i].Pages);
printf("The dop of book (DD-MM-YYYY): %d-%d-%d \n", book[i].dop.day ,book[i].dop.month ,book[i].dop.year);
}
return 0;
}
//1D array
// int main () {
// int a[10], b[10];
// int m,n;
// printf("Enter the no of elements in A : ");
// scanf("%d", &m);
// printf("Enter the elements of A :");
// for(int i=0; i<m; i++){
// scanf("%d", &a[i]);
// }
// // printf("Enter the no of elements in B : ");
// // scanf("%d", &n);
// // printf("Enter the elements of B :");
// // for(int i=0; i<n; i++){
// // scanf("%d", &b[i]);
// // }
// int k, pos;
// printf("Enter the element to append : ");
// scanf("%d", &k);
// printf("Enter the position :");
// scanf("%d", &pos);
// //For insertion
// // for(int i=m-1; i>=pos; i--){
// // a[i+1] =a[i];
// // } a[pos] = k;
// // m++;
// //For deletion
// // for(int i=pos; i<m-1; i++){
// // a[i] = a[i+1];
// // }m--;
// for(int i=0; i<m; i++){
// printf("%d ", a[i]);
// }
// return 0;
// }
//2D array
// int main() {
// int a[5][5], b[5][5];
// int m,n ,p,q;
// printf("Enter the number of rows and column in matrix A : ");
// scanf("%d %d", &m, &n);
// printf("Enter the elements :");
// for (int i=0; i<m; i++){
// for(int j=0; j<n; j++){
// scanf("%d", &a[i][j]);
// }
// }
// printf("Enter the number of rows and column in matrix B : ");
// scanf("%d %d", &p, &q);
// printf("Enter the elements :");
// for (int i=0; i<p; i++){
// for(int j=0; j<q; j++){
// scanf("%d", &b[i][j]);
// }
// }
// //Matrix Multiplication
// // if(n==p) printf("Matrix multiplication is possible ");
// // else {
// // printf("Matrix multiplication not possible ");
// // return 0;
// // }
// // int c[20][20];
// // for(int i=0; i<m; i++) {
// // for(int j=0; j<q; j++){
// // c[i][j] = 0;
// // for(int k=0; k<n; k++){
// // c[i][j] += a[i][k] * b[k][j];
// // }
// // }
// // }
// // printf("The Product Matrix is :");
// // for (int i=0; i<m; i++){
// // for(int j=0; j<q; j++){
// // printf("%d", c[i][j]);
// // }
// // }
// //SUM
// // int c[5][5];
// // if (m==x && n==y) {
// // printf("The sum is possible\n");
// // printf("The sum of 2 matrix is :");
// // printf("\n");
// // for (int i=0; i<m; i++){
// // for (int j=0; j<n; j++){
// // c[i][j] = a[i][j] + b[i][j];
// // printf("%d\t", c[i][j]);
// // }printf("\n");
// // }
// // }
// return 0;
// }