Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started