-
Notifications
You must be signed in to change notification settings - Fork 0
/
Lecture6 ConditionalStatements.c
73 lines (60 loc) · 1.39 KB
/
Lecture6 ConditionalStatements.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
#include <stdio.h>
#include <stdlib.h>
//Written by Bunyamin Yavuz in 2022
// Conditional Statements (if,else if,else)
int main()
{
/*
<-------General Structure of conditional statement------->
if (test - expression 1)
{
statement1;
}
else if (test - expression 2)
{
Statement2;
}
else if (test - expression 3)
{
Statement3;
}
else if (test - expression n)
{
statement n;
}
else
{
default;
}
*/
/*
Overall avarage calculator and also checking failed or passed the lecture
Formula = firstExam*0.3 + secondExam*0.5 + project*0.2
*/
int firstExam,secondExam,project;
float overallAvg;
printf("Enter your first exam grade: ");
scanf("%d",&firstExam);
printf("Enter your second exam grade: ");
scanf("%d",&secondExam);
printf("Enter your project exam grade: ");
scanf("%d",&project);
overallAvg = firstExam*0.3 + secondExam*0.5 + project*0.2;
if(overallAvg >= 85)
{ // After the comma %.(number)f example; (%.2f --> 2.52)
printf("AA %.2f -->Passed",overallAvg);
}
else if(overallAvg >= 70)
{
printf("BB %.2f -->Passed",overallAvg);
}
else if(overallAvg >= 50)
{
printf("CC %.2f -->Passed",overallAvg);
}
else
{
printf("FF %.2f -->Failed",overallAvg);
}
return 0;
}