www.bit.ly/vucodes

+ Link For Assignments, GDBs & Online Quizzes Solution

www.bit.ly/papersvu

+ Link For Past Papers, Solved MCQs, Short Notes & More

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.


#include<iostream>
using namespace std;
void convert(int);
main(){
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: ";
convert(number);
cout endl;
}
coutendl;
system("pause");
return 0;
}
void convert(int number) {
int remainder;

if(number <= 1) {
cout number;
return;
}

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

Download the attachment file given below


+ http://bit.ly/vucodes (Link for Assignments, GDBs & Online Quizzes Solution)

+ http://bit.ly/papersvu (Link for Past Papers, Solved MCQs, Short Notes & More)

+ Click Here to Search (Looking For something at vustudents.ning.com?)

+ Click Here To Join (Our facebook study Group)


Views: 203

Attachments:

Replies to This Discussion

good job 

thanku

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

kr sakty hen convert 

RSS

Looking For Something? Search Below

Latest Activity

+ !! Ήලᵯᵯℹ Ⲥⱨ !! + liked + !! Ήලᵯᵯℹ Ⲥⱨ !! +'s discussion !!!! !!!!!!
5 minutes ago
+ !! Ήලᵯᵯℹ Ⲥⱨ !! + liked + !! Ήලᵯᵯℹ Ⲥⱨ !! +'s discussion !!!!TRUE LOVE NEVER DIES!!!!
5 minutes ago
+ !! Ήලᵯᵯℹ Ⲥⱨ !! + liked Zoha n's discussion ......!!!! (^◡^ )
5 minutes ago
+ !! Ήලᵯᵯℹ Ⲥⱨ !! + liked D$OuLoVeRwHeLm€d's discussion dildar❤
5 minutes ago
+ !! Ήලᵯᵯℹ Ⲥⱨ !! + liked D$OuLoVeRwHeLm€d's discussion Larnei Ko Tiyar
5 minutes ago
+ !! Ήලᵯᵯℹ Ⲥⱨ !! + liked D$OuLoVeRwHeLm€d's discussion Mohabbat
5 minutes ago
+ M.Tariq Malik replied to + M.Tariq Malik's discussion CS201 Introduction to Programming Assignment No 03 Fall 2020 Solution & Discussion in the group CS201 Introduction to Programming
16 minutes ago
+ M.Tariq Malik replied to + M.Tariq Malik's discussion CS601 Solved MCQs Online Quiz No 02 Fall 2020 Solution / Discussion in the group CS601 Data Communication
21 minutes ago
+ M.Tariq Malik liked + !! Ήලᵯᵯℹ Ⲥⱨ !! +'s discussion !!!!TRUE LOVE NEVER DIES!!!!
37 minutes ago
+ M.Tariq Malik replied to + M.Tariq Malik's discussion EDU602 GDB Fall 2020 Solution / Discussion in the group EDU602 Educational Leadership and Management
37 minutes ago
+ M.Tariq Malik replied to + M.Tariq Malik's discussion EDU602 GDB Fall 2020 Solution / Discussion in the group EDU602 Educational Leadership and Management
39 minutes ago
+ M.Tariq Malik added a discussion to the group EDU602 Educational Leadership and Management
40 minutes ago

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

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

.