-
Notifications
You must be signed in to change notification settings - Fork 0
/
calc1.c
85 lines (79 loc) · 2.51 KB
/
calc1.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#include <stdio.h>
#include <time.h>
//BodyMassIndex bmi_calc
void delay2(float number_of_seconds);
void bmi_calc(float weight, float length);
void calc1()
{
float weight, length;
int parameter;
//title
printf("*****************************************************\n");
printf("* *\n");
printf("* *\n");
printf("* Welcome To Calculate BodyMassIndex *\n");
printf("* *\n");
printf("* *\n");
printf("*****************************************************\n");
delay2(4);
system("clear");
do
{
//title
printf("Select parameter:\n");
printf("*****************************************************\n");
printf("* *\n");
printf("* 1-Calculate BodyMassIndex *\n");
printf("* 2-Exit *\n");
printf("* *\n");
printf("*****************************************************\n");
scanf("%d", ¶meter);
system("clear");
switch (parameter)
{
case 1://calculate
printf("Enter Your Weight(kg): ");
scanf("%f", &weight);
printf("Enter Your Length(m): ");
scanf("%f", &length);
bmi_calc(weight, length);
printf("\n");
delay2(4);
break;
case 2://exit
printf("\n");
break;
default:
printf("Invalid Parameter!!!\n");
break;
}
}
while (parameter != 2);
//exit
printf("See You Later. Stay Healthy :))))");
}
//function bodymasscalculator
void bmi_calc(float weight, float length)
{
float result;
result = weight / (length * length);
if (result >= 20 && result <= 25)
{
printf("You are calculated as Normal\n");
}
else if (result > 25)
{
printf("You are calculated as Overweight\n");
}
else if (result < 20)
{
printf("You are calculated as Thin\n");
}
}
//delay
void delay2(float number_of_seconds)
{
float milli_seconds = 1000 * number_of_seconds;
clock_t start_time = clock();
while (clock() < start_time + milli_seconds);
}