forked from PriyaGhosal/SkillWise
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhello.c
29 lines (28 loc) · 819 Bytes
/
hello.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
#include <stdio.h>
int main() {
int num1, num2, choice;
printf("Enter two numbers: ");
scanf("%d %d", &num1, &num2);
printf("Choose an operation (+, -, \*, /): ");
scanf(" %c", &choice);
switch (choice) {
case '+':
printf("%d + %d = %d\n", num1, num2, num1 + num2);
break;
case '-':
printf("%d - %d = %d\n", num1, num2, num1 - num2);
break;
case '*':
printf("%d * %d = %d\n", num1, num2, num1 * num2);
break;
case '/':
if (num2 != 0)
printf("%d / %d = %f\n", num1, num2, (float)num1 / num2);
else
printf("Error: Division by zero!\n");
break;
default:
printf("Invalid choice!\n");
}
return 0;
}