|
|
@ -33,7 +33,7 @@ long long int BinToDec(long long int n) { |
|
|
|
return dec; |
|
|
|
} |
|
|
|
//addition |
|
|
|
long long int addition(long long int a, long long int b) { |
|
|
|
long long int additionbin(long long int a, long long int b) { |
|
|
|
long long int dec1, dec2; |
|
|
|
dec1 = BinToDec(a); |
|
|
|
dec2 = BinToDec(b); |
|
|
@ -43,7 +43,7 @@ long long int addition(long long int a, long long int b) { |
|
|
|
return dec2; |
|
|
|
} |
|
|
|
// multiplication |
|
|
|
long long int multiplication(long long int a, long long int b) { |
|
|
|
long long int multiplicationbin(long long int a, long long int b) { |
|
|
|
long long int dec1, dec2; |
|
|
|
dec1 = BinToDec(a); |
|
|
|
dec2 = BinToDec(b); |
|
|
@ -53,7 +53,7 @@ long long int multiplication(long long int a, long long int b) { |
|
|
|
return dec2; |
|
|
|
} |
|
|
|
//subtraction |
|
|
|
long long int subtraction(long long int a, long long int b) { |
|
|
|
long long int subtractionbin(long long int a, long long int b) { |
|
|
|
long long int dec1, dec2; |
|
|
|
dec1 = BinToDec(a); |
|
|
|
dec2 = BinToDec(b); |
|
|
@ -99,7 +99,7 @@ int main() { |
|
|
|
scanf("%lld", &bin1); |
|
|
|
printf("enter the second binary number: "); |
|
|
|
scanf("%lld", &bin2); |
|
|
|
result = addition(bin1, bin2); |
|
|
|
result = additionbin(bin1, bin2); |
|
|
|
|
|
|
|
printf("%lld+%d = %lld\n", bin1, bin2, result); |
|
|
|
break; |
|
|
@ -108,7 +108,7 @@ int main() { |
|
|
|
scanf("%lld", &bin1); |
|
|
|
printf("enter the second binary number: "); |
|
|
|
scanf("%lld", &bin2); |
|
|
|
result = subtraction(bin1, bin2); |
|
|
|
result = subtractionbin(bin1, bin2); |
|
|
|
|
|
|
|
printf("%lld-%lld = %lld\n", bin1, bin2, result); |
|
|
|
break; |
|
|
@ -117,7 +117,7 @@ int main() { |
|
|
|
scanf("%lld", &bin1); |
|
|
|
printf("enter the second binary number: "); |
|
|
|
scanf("%lld", &bin2); |
|
|
|
result = multiplication(bin1, bin2); |
|
|
|
result = multiplicationbin(bin1, bin2); |
|
|
|
|
|
|
|
printf("%lld*%d = %lld\n", bin1, bin2, result); |
|
|
|
break; |
|
|
|