Latest Activity In Study Groups

Join Your Study Groups

VU Past Papers, MCQs and More

We non-commercial site working hard since 2009 to facilitate learning Read More. We can't keep up without your support. Donate.

Decimal to Binary conversion in c++ by using the Recursion

See the code given below i sure you will found some errors while compiling this code. So, please don't forget to put less than and greater than expression after cout and cin. these expression has been removed due to the ning.api does not support to these expression so put them after cin and cout.
This code will convert to a Decimal number into Binary code.
we will learn in this code:

  1. Functions
  2. Recursion 
  3. Use of Modulus operator 

I hope you can understand this code easily. if you have any problem then you may ask.

using namespace std;
void convert(int);
int number;

cout "Please enter a positive integer: ";
cin >> number;
if (number < 0)
cout "That is not a positive integer.\n";
else {
cout endl number " converted to binary is: ";
cout endl;
return 0;
void convert(int number) {
int remainder;

if(number <= 1) {
cout number;

remainder = number%2;
convert(number >> 1);
cout remainder;

Download the attachment file given below

Views: 212


Replies to This Discussion

good job 


agr vaule -ve ho to kia us ko binary mn convert ni kia ja skta??? is mn +ve hi q?

kr sakty hen convert 


Looking For Something? Search Below

Latest Activity

© 2022   Created by + M.Tariq Malik.   Powered by

Promote Us  |  Report an Issue  |  Privacy Policy  |  Terms of Service