Convert Decimal to Binary using RECURSION !
#include <bits/stdc++.h>
using namespace std;
int bin(int num)
{
static int a = 0;
if (num / 2 != 0)
bin(num / 2);
a = a * 10 + num % 2;
return a;
}
int main()
{
int num;
cout << "Enter the Number : ";
cin >> num;
cout << "The binary number will be : " << bin(num) << endl;
}
Comments
Post a Comment