-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path62.cpp
58 lines (51 loc) · 809 Bytes
/
62.cpp
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
//C++ Program to Convert Int Long Double to Absolute Values.
#include<iostream>
//using namespace std;
using std::cout;
using std::cin;
int abs(int n);
long abs(long n);
double abs(double n);
int abs(int n)
{
if(n<0)
{
return(n*(-1));
}
else
{
return n;
}
}
long abs(long n)
{
if(n<0)
{
return(n*(-1));
}
else
{
return n;
}
}
double abs(double n)
{
if(n<0)
{
n = (n*(-1));
int y = (int)(n);
return(y);
}
else
{
int y = (int)(n);
return(y);
}
}
int main()
{
cout<< abs(-10) <<'\n';
cout<< abs(-10l) <<'\n';
cout<< abs(11.99) <<'\n';
return 0;
}