-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLab_2.c
124 lines (100 loc) · 2.48 KB
/
Lab_2.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
// Lab2.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "stdio.h"
int main()
{
int englishMark = 0;
int scienceMark = 0;
int frenchMark = 0;
int irishMark = 0;
int economicsMark = 0;
int highestMark = 0;
float averageMark = 0.0f;
bool failedEnglish;
bool failedScience;
bool failedFrench;
bool failedIrish;
bool failedEconomics;
printf("Enter English mark:\t");
scanf_s("%d", &englishMark);
printf("Enter Science mark:\t");
scanf_s("%d", &scienceMark);
printf_s("Enter French mark:\t");
scanf_s("%d", &frenchMark);
printf("Enter Irish mark:\t");
scanf_s("%d", &irishMark);
printf_s("Enter Economics Mark:\t");
scanf_s("%d", &economicsMark);
averageMark = (englishMark + scienceMark + frenchMark + irishMark + economicsMark)/5;
printf("The average mark is:%.2f \n", averageMark);
failedIrish = (irishMark < 40);
failedScience = (scienceMark < 40);
failedFrench = (frenchMark < 40);
failedEconomics = (economicsMark < 40);
failedEnglish = (englishMark < 40);
printf("Fails:");
if (failedIrish)
{
printf("Irish, ");
}
if (failedEconomics)
{
printf("Economics, ");
}
if (failedEnglish)
{
printf("English, ");
}
if (failedFrench)
{
printf("French, ");
}
if (failedScience)
{
printf("Science, ");
}
printf("\nPassed:");
if (!failedIrish)
{
printf("Irish, ");
}
if (!failedEconomics)
{
printf("Economics, ");
}
if (!failedEnglish)
{
printf("English, ");
}
if (!failedFrench)
{
printf("French, ");
}
if (!failedScience)
{
printf("Science, ");
}
if ((englishMark > scienceMark)&&(englishMark>irishMark)&&(englishMark>economicsMark)&&(englishMark>frenchMark))
{
highestMark = englishMark;
}
if ((scienceMark > englishMark) && (scienceMark>irishMark) && (scienceMark>economicsMark) && (scienceMark>frenchMark))
{
highestMark = scienceMark;
}
if ((frenchMark > scienceMark) && (frenchMark>irishMark) && (frenchMark>economicsMark) && (frenchMark>englishMark))
{
highestMark = frenchMark;
}
if ((irishMark > scienceMark) && (irishMark>englishMark) && (irishMark>economicsMark) && (irishMark>frenchMark))
{
highestMark = irishMark;
}
if ((economicsMark > scienceMark) && (economicsMark>irishMark) && (economicsMark>englishMark) && (economicsMark>frenchMark))
{
highestMark = economicsMark;
}
printf("\nHighest Mark:%d \n",highestMark);
return 0;
}