decimal to binary in C++ without using any array or functions
Answers
Answered by
0
Explanation:
#include <iostream>
#include <conio.h>
using namespace std;
int main()
{
int num;
int array[10],k=0;
int n;
cout<<"enter any number which is greater than 0:";
cin>>num;
while(num>0)
{
array[k]=num%2;
num=num/2;
k++;
}
cout<<"output in form of binary number is:";
for(n=k-1;n>=0;n--)
{
cout<<array[n];
}
}
Answered by
0
Answer:
#include <iostream>
#include <conio.h>
using namespace std;
int main()
{
int num;
int array[10],k=0;
int n;
cout<<"enter any number which is greater than 0:";
cin>>num;
while(num>0)
{
array[k]=num%2;
num=num/2;
k++;
}
cout<<"output in form of binary number is:";
for(n=k-1;n>=0;n--)
{
cout<<array[n];
}
}
this is the equation to change
Similar questions