forked from kushalsingh-00/C-Programs
-
Notifications
You must be signed in to change notification settings - Fork 1
/
calculation_switch.c
45 lines (40 loc) · 1 KB
/
calculation_switch.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
39
40
41
42
43
44
45
/*
-------------------------------------------------------
Name : Arithmatic Operation
Author : Kushal Singh Rathore
Discription : Calcultion By Using Switch
-------------------------------------------------------
*/
#include<stdio.h>
#include<stdlib.h>
int main()
{
char y;
float a,b,c,d;
printf("Enter the first number\n");
scanf("%f",&a);
printf("Enter the second number\n");
scanf("%f",&b);
getchar();
printf("Enter the operation:\n+\n-\n*\n/\n");
scanf("%c",&y);
switch(y)
{
case '+':c=a+b; //Case label 1
printf("ADDITION of two numbers is %f",c);
break;
case '-': c=a-b;
printf("SUBTRACTION of two numbers is %f ",c);
break;
case '*': c=a*b;
printf("MUTIPICATIOM of two numbers is %f",c);
break;
case '/': d=a/b;
printf("DIVISON of two numbers is %f ",d);
break;
default:
printf("Invalid operator");
break;
}
return 0;
}