-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquiz3-4.c
66 lines (59 loc) · 1.46 KB
/
quiz3-4.c
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
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
typedef struct
{
char name[64];
int population;
int area;
char primeMinisterName[64];
} Province;
Province setData(int a);
void printProvince(Province c[11]);
int main()
{
int a;
Province CanadianProvince[11];
for(a = 0; a<4; a++){
CanadianProvince[a] = setData(a);
}
printProvince(CanadianProvince);
}
Province setData(int a){
Province c;
char name[64];
int population, area;
char pmName[64];
printf("\n\n\nEnter Prov %d detail:",a+1);
printf("\nName:");
scanf("%s",&name);
strcpy(c.name,name);
printf("\nArea:");
scanf("%d",&area);
c.area = area;
printf("\nPopulation:");
scanf("%d",&population);
c.population = population;
printf("\nPrime Minister's Name:");
scanf("%s",&pmName);
strcpy(c.primeMinisterName,pmName);
return c;
}
void printProvince(Province c[]){
printf("\n\n\nAll the Province Details:\nName\t\tPopulation\t\tArea\t\tPrime\n\n");
int a=0;
for(a = 0; a<4; a++){
printf("%s\t\t%d\t\t\t%d\t\t%s\n",&c[a].name,c[a].population,c[a].area,&c[a].primeMinisterName);
}
char name[64];
printf("\n\n\n\n\nEnter a privince name: ");
scanf("%s",&name);
int i=0;
for(i = 0; i<4; i++){
if(strcmp(&c[i].name,name)){
printf("\n\n\n%s Province Details:\nName\t\tPopulation\t\tArea\t\tPrime\n\n",name);
printf("%s\t\t%d\t\t\t%d\t\t%s\n",&c[i].name,c[i].population,c[i].area,&c[i].primeMinisterName);
break;
}
}
}