-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathall_operations.c
More file actions
31 lines (26 loc) · 768 Bytes
/
Copy pathall_operations.c
File metadata and controls
31 lines (26 loc) · 768 Bytes
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
#include <stdio.h>
int main()
{
int m1, m2, sum, diff, prod;
float div;
printf("Enter marks of subject 1: ");
scanf("%d", &m1);
printf("Enter marks of subject 2: ");
scanf("%d", &m2);
// Calculate all operations
sum = m1 + m2;
diff = m1 - m2;
prod = m1 * m2;
div = (float)m1 / m2;
// Display results with matching formatting
printf("\n=============================\n");
printf("%-20s%d\n", "Total marks:", sum);
printf("%-20s%d\n", "Difference:", diff);
printf("%-20s%d\n", "Product:", prod);
if (m2 != 0) {
printf("%-20s%.2f\n", "Division:", div);
} else {
printf("%-20s%s\n", "Division:", "Undefined (Div by 0)");
}
printf("=============================\n");
}