summary refs log tree commit diff stats
path: root/assignments/01-grading-system.c
diff options
context:
space:
mode:
authorsmlckz <smlckz@college>2021-12-22 14:56:13 +0530
committersmlckz <smlckz@college>2021-12-22 14:56:13 +0530
commitb73983c3717642ca10e7cfe93d97609adc377da9 (patch)
treea6e9fe4c27e3caa215f8aefa9265fb52f6de4375 /assignments/01-grading-system.c
downloadcollege-b73983c3717642ca10e7cfe93d97609adc377da9.tar.gz
backup
Diffstat (limited to 'assignments/01-grading-system.c')
-rw-r--r--assignments/01-grading-system.c63
1 files changed, 63 insertions, 0 deletions
diff --git a/assignments/01-grading-system.c b/assignments/01-grading-system.c
new file mode 100644
index 0000000..3c15f24
--- /dev/null
+++ b/assignments/01-grading-system.c
@@ -0,0 +1,63 @@
+/* Grading system */
+#include <stdio.h>
+
+int main(void)
+{
+	int n1, n2, n3, n4;
+	float avg;
+	printf("Grading system\n\n");
+	printf("Enter marks obtained in four subjects: ");
+	scanf("%d%d%d%d", &n1, &n2, &n3, &n4);
+	avg = (float)(n1 + n2 + n3 + n4)/4;
+	printf("The average of the marks is %f\n", avg);
+	if (avg >= 80)
+		printf("The student has grade A.\n");
+	if (avg >= 60 && avg < 80)
+		printf("The student has grade B.\n");
+	if (avg >= 40 && avg < 60)
+		printf("The student has grade C.\n");
+	if (avg < 40)
+		printf("The student has failed.\n");
+	return 0;
+}
+
+/*
+Output:
+Set 1:
+Grading system
+
+Enter marks obtained in four subjects: 81
+85
+86
+91
+The average of the marks is 85.750000
+The student has grade A.
+
+Set 2:
+Grading system
+
+Enter marks obtained in four subjects: 86 75 71 42
+The average of the marks is 68.500000
+The student has grade B.
+
+Set 3:
+Grading system
+
+Enter marks obtained in four subjects: 45
+55
+51
+42
+The average of the marks is 48.250000
+The student has grade C.
+
+Set 4:
+Grading system
+
+Enter marks obtained in four subjects: 25
+31
+40 32
+The average of the marks is 32.000000
+The student has failed.
+
+*/
+