forked from sarjus/C-Programing-KTU
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexp2_1_sarju_s.c
38 lines (37 loc) · 1.14 KB
/
exp2_1_sarju_s.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
/******************************************************
* File : Experiment 2.1
* Description : C Program demonstrate a calculator(+,-,*, /, %)
* Author : Sarju S
* Version : 1.0
* Date : 08/06/2021
* ***************************************************/
#include<stdio.h>
int main(){
int number1, number2;
char operator;
printf("\nEnter the operations to be performed(+,-,*, /, %%) ");
scanf("%c",&operator);
printf("\nEnter two integer numbers:");
scanf("%d%d",&number1,&number2);
switch(operator){
case '+':
printf("\nSum=%d",number1+number2);
break;
case '-':
printf("Difference=%d",number1-number2);
break;
case '*':
printf("Multiplication=%d",number1*number2);
break;
case '/':
printf("Division=%f",(float)number1/number2);
break;
case '%':
printf("Modulus=%d",number1%number2);
break;
default:
printf("Invalid Operator");
break;
}
return 0;
}