-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcalculator.c
More file actions
62 lines (62 loc) · 1.36 KB
/
calculator.c
File metadata and controls
62 lines (62 loc) · 1.36 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include<stdio.h>
#include<math.h>
int main()
{
int choice,num1,num2,num;
printf("Welcome to my mini project!!\n1.Addition\n2.Subtraction\n3.Multiplication\n4.Division\n5.Square\n6.Cube\n7.Root\nEnter your choice : ");
scanf("%d",&choice);
if(choice >=1 && choice<=4)
{
printf("\nEnter 2 Numbers:\n");
scanf("%d%d",&num1,&num2);
}
else if(choice>4 && choice <=7)
{
printf("\nEnter 1 Number:\n");
scanf("%d",&num);
}
switch(choice)
{
case 1:
{
printf("\nSum is %d",num1+num2);
break;
}
case 2:
{
printf("\nDifference is %d",num1-num2);
break;
}
case 3:
{
printf("\nProduct is %d",num1*num2);
break;
}
case 4:
{
printf("\nQuotient is %d \nRemainder is %d",num1/num2,num1%num2);
break;
}
case 5:
{
printf("\nSquare is %d",num*num);
break;
}
case 6:
{
printf("\nCube is %d",num*num*num);
break;
}
case 7:
{
float srt = sqrt(num);
printf("\nRoot is %.2f",srt);
break;
}
default:
{
printf("Invalid Input");
break;
}
}
}