convert a number into binary in C++ (C Plus Plus CPP) and C with the flowchart
In this tutorial, we will learn about the followings;
- Flowchart of program to convert a number into binary
- convert a number into binary in C++ C plus plus
- convert a number into binary in C
Flowchart of program to convert a number into binary

convert a number into binary in C++ C plus plus
#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 then 0:";
cin>>num;
while(num>0)
{
array[k]=num%2;
num=num/2;
k++;
}
cout<<"output infoam of binary number is:";
for(n=k-1;n>=0;n--)
{
cout<<array[n];
}
}
Output

convert a number into binary in C
#include <stdio.h>
void main()
{
int n, i, j, BinaryNumber=0,x;
printf("Convert a Decimal number into Binary number: \n");
printf("Enter a number in decimal to convert it into binary number: \n");
scanf("%d",&n);
x=n;
i=1;
for(j=n;j>0;j=j/2)
{
BinaryNumber=BinaryNumber+(n%2)*i;
i=i*10;
n=n/2;
}
printf("The Binary of %d is %d.\n",x,BinaryNumber);
}
Output

