-
Notifications
You must be signed in to change notification settings - Fork 0
/
bloodgroup.c
executable file
·48 lines (47 loc) · 1.49 KB
/
bloodgroup.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
#include <stdio.h>
#include <string.h>
void main()
{ char Name[50], G[5], answer[10];
int i;
do
{
printf("What is your name? ");
scanf("%s", Name);
do
{
printf("What is your blood group [A, B, AB, or O]? ");
scanf("%s", G);
if (strcmp(G, "A") !=0 &&
strcmp(G, "B") !=0 &&
strcmp(G, "AB") !=0 &&
strcmp(G, "O") !=0 )
printf("Blood group %s is incorrect! Please try again.\n", G);
} while (strcmp(G, "A") !=0 &&
strcmp(G, "B") !=0 &&
strcmp(G, "AB") !=0 &&
strcmp(G, "O") !=0 );
if (strcmp(G,"A") ==0)
{
printf("%s, A. Hey, you can give blood to: A, AB.\n", Name);
printf(" You can receive blood from: A, O.\n");
}
else if (strcmp(G, "B") ==0)
{
printf("%s, B. Well, you can give blood to: B, AB.\n", Name);
printf(" You can receive blood from: B, O.\n");
}
else if (strcmp(G, "AB") == 0)
{
printf("%s, AB. Oh my God, you can give blood only to: AB.\n", Name);
printf(" Wow, you can receive blood from all: O, A, B, AB.\n");
}
else
{
printf("%s, O. Nice! You can give blood to all: O, A, B, AB\n", Name);
printf(" But Sad! You can receive blood only from: O\n");
}
printf("\nContinue (YES for Yes)? ");
scanf("%s", answer);
} while (strcmp(answer, "YES") == 0);
printf("Goodbye\n");
}