Question: C++ Need help to convert large decimal to binary in the program without using arrays/functions. When enter more than 4 digits, it doesn't work. #include
C++ Need help to convert large decimal to binary in the program without using arrays/functions. When enter more than 4 digits, it doesn't work.
#include
int main() { float decimal, binary = 0, multiply = 1, remainder;
cout << "Enter decimal number: "; cin >> decimal; cout << "The binary representation of " << decimal ; { while (decimal > 0) { remainder = decimal % 2; binary = binary + ( remainder * multiply ); multiply = multiply * 10; decimal = decimal / 2; } } cout <<" is " << binary << endl; return 0; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
