-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQ4.cpp
More file actions
72 lines (54 loc) · 1.02 KB
/
Q4.cpp
File metadata and controls
72 lines (54 loc) · 1.02 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
63
64
65
66
67
68
69
70
71
72
#include<iostream>
using namespace std;
int main(){
cout<<"Enter 1 For Addition\n Enter 2 for Subtraction\n Enter 3 for Mulitplication \n Enter 4 for Division\n Enter 5 for absolute function";
int q;
float a,b,c,d;
cout<<"\nEnter Value of Q:";
cin>>q;
cout<<"Enter value of a:";
cin>>a;
cout<<"Enter value of b:";
cin>>b;
if(q==1){
c=a+b;
cout<<"Value is:"<<c;
}
else if(q==2){
c=a-b;
cout<<"Value is:"<<c;
}
else if(q==3){
c=a*b;
cout<<"Value is:"<<c;
}
else if(q==4){
c=a/b;
cout<<"Value is:"<<c;
}
if ( q==5 && a<0 && b<0){
c=a*-1;
d=b*-1;
cout<<"Value is:"<<c;
cout<<"\nValue is:"<<d;
}
else if ( q==5 && a>0 && b<0){
c=a*1;
d=b*-1;
cout<<"Value is:"<<c;
cout<<"\nValue is:"<<d;
}
else if ( q==5 && a<0 && b>0){
c=a*-1;
d=b*1;
cout<<"Value is:"<<c;
cout<<"\nValue is:"<<d;
}
else if ( q==5 && a>0 && b>0){
c=a*1;
d=b*1;
cout<<"Value is:"<<c;
cout<<"\nValue is:"<<d;
}
return 0;
}