New course! Every coder should learn Generative AI!
Try a free lesson+ 3
#include <iostream>
using namespace std;
int main() {
int i,in,n,bi[30],j;
cout << "Please enter any decimal number\n";
cin >> in;
i=0;
j=in;
while(in>0)
{
n=in%2;
bi[i++] = n;
in = in/2;
}
cout << "You have entered " << j << endl;
cout << "Your binary number is ";
for(n=i-1;n>=0;n--)
cout << bi[n];
return 0;
}