#include
using namespace std;
int main()
//sourcea.ir
{
int dec, bin[16], i = 0, j = 0; //dec and bin to store number and ints binary equivalent and i&j are //for index maintaining
cout << "Enter a decimal number\n";
cin >> dec;
while (dec > 0) //calculating the binary equivalent and storing it in the array
{
bin[i] = dec % 2;
dec = dec / 2;
++i;
}
cout << "Binary Equivalent:"; //printing the array in reverse order
for (j = i - 1; j >= 0; --j)
cout << bin[j];
return 0;
}
توضیحات:
صورت سوال:
برنامه تبدیل عدد حقیقی به باینری در C++
این برنامه عدد را از شما گرفته و آن را به باینری تبدیل و چاپ میکند.
موفق باشید
A.J