-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathletscode.c
More file actions
32 lines (30 loc) · 875 Bytes
/
letscode.c
File metadata and controls
32 lines (30 loc) · 875 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
32
#include <stdio.h>
int main(){
int a,b;
int c;
printf("Enter the value of a: ");
scanf("%d", &a);
printf("Entre the value of b: ");
scanf("%d", &b);
printf("Enter your operation: 1 for addition/ 2 for substraction/ 3 for multiplication / 4 for division/ 5 for average");
scanf("%d", &c);
switch (c)
{
case 1:
printf("%d",a+b); // 1 for addition
break; // 2 for substraction
case 2: // 3 for multiplication
printf("%d",a-b); // 4 for division
break; // 5 for average
case 3:
printf("%d",a*b);
break;
case 4:
printf("%d",a/b);
break;
case 5:
printf("%d",(a+b)/2); // '_' is used here for calculating average
break;
}
return 0;
}