forked from Tomkndn/C
-
Notifications
You must be signed in to change notification settings - Fork 2
/
percentage.c
47 lines (43 loc) · 1.17 KB
/
percentage.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
#include <stdio.h>
float science(float n, float m){
float Res = (n/m)*100.0;
return Res;
}
float math(float n, float m){
float Res = (n/m)*100.0;
return Res;
}
float sanskrit(float n, float m){
float Res = (n/m)*100.0;
return Res;
}
int main(){
char A;
printf("<<Enter Your Subject>>\n");
printf("Enter 's' for Science, 'm' for Math and 'k' for Sanskrit: ");
scanf("%c", &A);
if (A == 's')
{
float B,C;
printf("Enter your obtained marks: ");
scanf("%f", &B);
printf("Enter Full Marks: ");
scanf("%f", &C);
printf("Your Obtained percentage in Science is: %.2f", science(B,C));
}else if(A == 'm'){
float B,C;
printf("Enter your obtained marks: ");
scanf("%f", &B);
printf("Enter Full Marks: ");
scanf("%f", &C);
printf("Your Obtained percentage in Math is: %.2f", math(B,C));
}else if (A == 'k')
{
float B,C;
printf("Enter your obtained marks: ");
scanf("%f", &B);
printf("Enter Full Marks: ");
scanf("%f", &C);
printf("Your Obtained percentage in Sanskrit is: %.2f", sanskrit(B,C));
}
}