Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 34dd571

Browse files
Add files via upload
1 parent 1791120 commit 34dd571

File tree

3 files changed

+243
-0
lines changed

3 files changed

+243
-0
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
## Code:
2+
```c
3+
#include <stdio.h>
4+
typedef struct family
5+
{
6+
char name_wife[20];
7+
int numb_child;
8+
char name_child[10][20];
9+
} family;
10+
typedef union details
11+
{
12+
family fam;
13+
char hobby[30];
14+
} details;
15+
typedef struct member
16+
{
17+
char name[20];
18+
int age;
19+
char addr[100];
20+
char active, married;
21+
details det;
22+
} member;
23+
void input(member c[2])
24+
{
25+
for (int i = 0; i < 2; i++)
26+
{
27+
printf("\n\nEnter the name of the member: ");
28+
scanf(" %s", c[i].name);
29+
printf("Enter the age of the person: ");
30+
scanf("%d", &c[i].age);
31+
printf("Enter the address of the person: ");
32+
scanf(" %[^\n]", c[i].addr);
33+
printf("Enter active status (Y/N): ");
34+
scanf(" %c", &c[i].active);
35+
printf("Enter Marital Status (Y/N): ");
36+
scanf(" %c", &c[i].married);
37+
if (c[i].married == 'Y')
38+
{
39+
printf("Enter name of the wife: ");
40+
scanf(" %s", c[i].det.fam.name_wife);
41+
printf("Enter the number of children: ");
42+
scanf("%d", &c[i].det.fam.numb_child);
43+
for (int i = 0; i < c[i].det.fam.numb_child; i++)
44+
{
45+
printf("Enter name of the children: ");
46+
scanf(" %s", c[i].det.fam.name_child[i]);
47+
}
48+
}
49+
else
50+
{
51+
printf("Enter the hobby of the member: ");
52+
scanf(" %[^\n]", c[i].det.hobby);
53+
}
54+
}
55+
}
56+
int main()
57+
{
58+
member c[2];
59+
input(c);
60+
printf("The list of married active players and their wives is as follows:\n");
61+
printf("Name\tWife");
62+
for (int i = 0; i < 2; i++)
63+
{
64+
if (c[i].active == 'Y' && c[i].married == 'Y')
65+
printf("\n%s\t%s\n", c[i].name, c[i].det.fam.name_wife);
66+
}
67+
return 0;
68+
}
69+
```
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
### Question 1:
2+
3+
## Code:
4+
```c
5+
#include <stdio.h>
6+
#include <string.h>
7+
typedef struct air
8+
{
9+
char src[4];
10+
char des[4];
11+
int start;
12+
int arrival;
13+
int seats;
14+
int count;
15+
} airline_t;
16+
void reset(airline_t c[5])
17+
{
18+
for (int i = 0; i < 5; i++)
19+
c[i].count = 0;
20+
}
21+
void input(airline_t c[5])
22+
{
23+
for (int i = 0; i < 5; i++)
24+
{
25+
printf("\nEnter the source: ");
26+
scanf("%s", c[i].src);
27+
printf("Enter the destination: ");
28+
scanf("%s", c[i].des);
29+
printf("Enter the starting time: ");
30+
scanf("%d", &c[i].start);
31+
printf("Enter the arriving time: ");
32+
scanf("%d", &c[i].arrival);
33+
printf("Enter the number of seats: ");
34+
scanf("%d", &c[i].seats);
35+
c[i].count = 0;
36+
}
37+
}
38+
int main()
39+
{
40+
int d = 1, temp = 0, n, flag = 0, seat;
41+
airline_t c[5];
42+
input(c);
43+
char source[4], dest[4];
44+
do
45+
{
46+
printf("\nEnter your source: ");
47+
scanf("%s", source);
48+
printf("Enter your destination: ");
49+
scanf("%s", dest);
50+
printf("\nStart\tEnd\tSeats\n");
51+
for (int i = 0; i < 5; i++)
52+
{
53+
if (strcmp(c[i].src, source) == 0 && strcmp(c[i].des, dest) == 0 &&
54+
c[i].seats > 0)
55+
{
56+
printf("%d\t%d\t%d\n", c[i].start, c[i].arrival, c[i].seats);
57+
c[i].count = d;
58+
d++;
59+
temp++;
60+
}
61+
}
62+
if (temp == 0)
63+
{
64+
printf("\nSorry we dont have any flights available");
65+
}
66+
else
67+
{
68+
printf("Enter the number of flight you want to take: ");
69+
scanf("%d", &n);
70+
printf("Enter the number of seats you want to book: ");
71+
scanf("%d", &seat);
72+
for (int i = 0; i < 5; i++)
73+
{
74+
if (n == c[i].count)
75+
{
76+
if (c[i].seats - seat >= 0)
77+
{
78+
c[i].seats -= seat;
79+
printf("Your flight has been booked for %s to %s", c[i].src, c[i].des);
80+
printf("\nTimings are follows: %d to %d", c[i].start, c[i].arrival);
81+
printf("\nNo of seats remaining: %d", c[i].seats);
82+
}
83+
else
84+
{
85+
printf("The flight does not have %d seats available", seat);
86+
printf("\nPlease select a different flight.");
87+
}
88+
}
89+
}
90+
}
91+
printf("Enter 0 to continue booking or any other number to exit");
92+
scanf("%d", &flag);
93+
reset(c);
94+
} while (flag == 0);
95+
return 0;
96+
}
97+
```
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#include <stdio.h>
2+
#include <string.h>
3+
typedef struct employee
4+
{
5+
char name[20];
6+
char gender;
7+
int salary;
8+
int day;
9+
int month;
10+
int year;
11+
int age;
12+
} employee;
13+
int main()
14+
{
15+
employee c[10];
16+
int i;
17+
char name[5][20];
18+
for (i = 0; i < 5; i++)
19+
{
20+
printf("Enter the name: ");
21+
scanf(" %s", c[i].name);
22+
printf("Enter the gender (M/F): ");
23+
scanf(" %c", &c[i].gender);
24+
printf("Enter the salary: ");
25+
scanf("%d", &c[i].salary);
26+
printf("Enter the Date of Birth (DD MM YYYY): ");
27+
scanf("%d %d %d", &c[i].day, &c[i].month, &c[i].year);
28+
c[i].age = 2022 - c[i].year;
29+
printf("\n");
30+
}
31+
printf("Amendments: ");
32+
for (int k = 0; k < 5; k++)
33+
{
34+
int flag = 0;
35+
printf("\nEnter the name: ");
36+
scanf(" %s", name[k]);
37+
for (int j = 0; j < 10; j++)
38+
{
39+
if (strcmp(c[j].name, name[k]) == 0)
40+
{
41+
int choice;
42+
printf("Enter 1 if employee has left and 2 if employee if the
43+
salary is to be modified: ");
44+
scanf("%d",&choice);
45+
if(choice == 1)
46+
c[j].salary = 0;
47+
else if(choice == 2)
48+
{
49+
printf("Enter the new salary: ");
50+
scanf("%d", &c[j].salary);
51+
}
52+
flag = 1;
53+
break;
54+
}
55+
}
56+
if (flag == 0)
57+
{
58+
strcpy(c[i].name, name[k]);
59+
printf("Enter the gender of the employee (M/F): ");
60+
scanf(" %c", &c[i].gender);
61+
printf("Enter the salary of the employee: ");
62+
scanf("%d", &c[i].salary);
63+
printf("Enter the date of birth (DD MM YYYY) : ");
64+
scanf("%d %d %d", &c[i].day, &c[i].month, &c[i].year);
65+
c[i].age = 2022 - c[i].year;
66+
i++;
67+
}
68+
}
69+
printf("Name\tGender\tSalary\tDate of Birth");
70+
for (int k = 0; k < i; k++)
71+
{
72+
if (c[k].age < 60 && c[k].salary != 0)
73+
printf("\n%s\t%c\t%d\t%d %d
74+
%d",c[k].name,c[k].gender,c[k].salary,c[k].day,c[k].month,c[k].year);
75+
}
76+
return 0;
77+
}

0 commit comments

Comments
(0)

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /