We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8bbeaec commit 988da0cCopy full SHA for 988da0c
exercises/binary_converter.cpp
@@ -9,7 +9,7 @@
9
10
using namespace std;
11
12
-void BinR(unsigned long int num){
+void BinR(long int num){
13
if(!num){
14
return;
15
}
@@ -26,7 +26,7 @@ void BinR(unsigned long int num){
26
27
28
int main(){
29
- unsigned long int num;
+ long int num;
30
31
cout << "Insert first number: ";
32
cin >> num;
@@ -36,6 +36,11 @@ int main(){
36
exit(1);
37
38
39
+ if(num < 0){
40
+ num *= -1;
41
+ cout<< "Warning: The given value is a negative number. Switching to "<< num << endl;
42
+ }
43
+
44
cout<< "The binary number is: ";
45
BinR(num);
46
0 commit comments