Skip to content

Commit a1e77c2

Browse files
authored
structures
1 parent c31f97b commit a1e77c2

File tree

2 files changed

+169
-0
lines changed

2 files changed

+169
-0
lines changed

A4 Q1.C

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
2+
#include<stdio.h>
3+
struct data{
4+
char name[40];
5+
int salary;
6+
int hours;
7+
}em[1];
8+
main(){
9+
int i;
10+
11+
printf("enter your working hours \n");
12+
printf("enter your name \n");
13+
printf("enter your salary \n");
14+
for(i=0;i<2;i++)
15+
{
16+
scanf("%d",&em[i].hours);
17+
scanf("%s",&em[i].name);
18+
scanf("%d",&em[i].salary);
19+
20+
}
21+
for(i=0;i<2;i++)
22+
{
23+
if(em[i].hours >= 8 && em[i].hours < 10 )
24+
{ int f;
25+
f=em[i].salary + 50;
26+
printf("name of employe :%s \n your final salary is : %d \n",em[i].name,f);
27+
}
28+
29+
if(em[i].hours == 10 )
30+
{ int f;
31+
f=em[i].salary + 100;
32+
printf("name of employe :%s \n your final salary is : %d \n",em[i].name,f);
33+
}
34+
35+
if(em[i].hours > 10 && em[i].hours <= 12 )
36+
{ int f;
37+
f=em[i].salary + 150;
38+
printf("name of employe :%s \n your final salary is : %d \n",em[i].name,f);
39+
}
40+
41+
}
42+
}

A4 Q2.c

+127
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
2+
#include<stdio.h>
3+
#include<string.h>
4+
struct library{
5+
int a_number;
6+
char name[100] ;
7+
char book_title[100];
8+
9+
}b[2];
10+
main(){
11+
12+
13+
int i;
14+
printf("enter book accession number \n enter author name \n enter book title\n");
15+
for(i=0;i<2;i++)
16+
{
17+
scanf("%d",&b[i].a_number);
18+
scanf("%s",&b[i].name);
19+
scanf("%s",&b[i].book_title);
20+
21+
}
22+
for(i=0;i<2;i++)
23+
{
24+
printf("%d \n",b[i].a_number);
25+
printf("% \ns",b[i].name);
26+
printf("%s \n",b[i].book_title);
27+
28+
}
29+
char name2[30];
30+
strcpy(b[2].name,name2);
31+
32+
for(i=0;i<2;i++)
33+
{
34+
if (strcmp(b[i].name,name2))
35+
{
36+
37+
printf("%d \n",b[i].a_number);
38+
printf("%s \n",b[i].name);
39+
printf("%s \n",b[i].book_title);
40+
}
41+
42+
43+
}
44+
char title[100];
45+
strcpy(b[2].book_title,title);
46+
int count=0 ;
47+
for(i=0;i<2;i++)
48+
{
49+
if ( strcmp(b[i].book_title,title))
50+
{
51+
count++;
52+
53+
}
54+
}
55+
int count2;
56+
57+
58+
printf("\nthe count of particular title books are=%d\n",count);
59+
for(i=0;i<2;i++)
60+
{ b[i].book_title;
61+
count2++;
62+
}
63+
printf("\nthe count of books are=%d\n",count2);
64+
int mm;
65+
printf("enter 0 for exit \n");
66+
scanf("%d",&mm);
67+
do{
68+
int mm;
69+
printf("enter 0 for exit \n");
70+
scanf("%d",&mm);
71+
char u ;
72+
char q;
73+
74+
printf("do you want to issue a book Y OR N? \n");
75+
scanf("%c",&u);
76+
77+
if(u == 'y' || u == 'Y')
78+
{
79+
80+
count2--;
81+
82+
}
83+
else
84+
{
85+
break;
86+
}
87+
88+
printf("do you want to give it back Y OR N \n ?");
89+
scanf("%c",&q);
90+
if(q=='Y'|| q == 'y')
91+
{
92+
93+
count2++;
94+
95+
}
96+
else{
97+
break;
98+
}
99+
100+
101+
102+
103+
}
104+
105+
while ( mm != 0 );
106+
}
107+
108+
109+
110+
111+
112+
113+
114+
115+
116+
117+
118+
119+
120+
121+
122+
123+
124+
125+
126+
127+

0 commit comments

Comments
 (0)