-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmark.c
More file actions
40 lines (39 loc) · 1.2 KB
/
mark.c
File metadata and controls
40 lines (39 loc) · 1.2 KB
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
/*
* Sun, 20 Nov - 2022
* Author : Melaku Negussie (Telegram -@Anonymous_M21)
*/
#include <stdio.h> // For printf(), sprintf(), scanf() functions
#include <stdlib.h> // For atoi() function
#include <string.h> // For strlen() function
#include <ctype.h> // For isdigit() function
int main(void) {
char b[8], c[8];
int a[5], ag = 0, toInt = -1;
for(int i = 0; i < 5; i++) {
while(1) {
printf("Enter Mark %i : ", i + 1);
scanf("%s", b);
sprintf(c, "%s", b);
for(unsigned int j = 0; j < strlen(c); j++) {
if(isdigit(c[j]) != 0) toInt = atoi(c);
else {
toInt = 0;
break;
}
}
if(toInt > 100) {
printf("Invalid mark, > 100. Enter again between 1-100!.\n");
continue;
}
if(toInt != 0) break;
else {
printf("Invalid mark. Enter again between 1-100!\n");
continue;
}
}
a[i] = toInt;
ag += a[i];
}
printf("__________________\nAggregate : %i\n", ag);
printf("Pecentile : %.2f%%\n", ((ag/500.0f) * 100));
}