Important alert: (current site time 11/23/2014 8:59:55 PM EDT)
 

VB icon

Decimal to Binay Conversion using recursive function

Email
Submitted on: 9/26/2007 7:41:15 AM
By: Sachindra Bharti 
Level: Advanced
User Rating: Unrated
Compatibility: Borland C++
Views: 18191
(About the author)
 
     Decimal to Binary conversion
 

INCLUDE files:

Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
//**************************************
//INCLUDE files for :Decimal to Binay Conversion using recursive function
//**************************************
Mentioned in the program
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
				
//**************************************
// Name: Decimal to Binay Conversion using recursive function
// Description:Decimal to Binary conversion
// By: Sachindra Bharti
//
// Inputs:Any Decimal number
//
// Returns:Binary Number
//
// Assumes:Must know decimal and binary numbers
//
// Side Effects:nil
//
//This code is copyrighted and has// limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=11714&lngWId=3//for details.//**************************************

#include<iostream.h>
#include<conio.h>
//decimal to binary conversion using recursive function
void dectobin(long n);
void main()
{
clrscr();
long n;
cout<<"\n Enter any decimal number :";
cin>>n;
dectobin(n); // calling of function
getch();
}
//definition of recursive function
void dectobin(long n)
 { int r;
if (n<=0) 
 {cout<<"\n Binary Equavalent is :";
return; }
r = n % 2;
dectobin(n/2);
cout<<r;
}
#include<iostream.h>
#include<conio.h>
//decimal to binary conversion using recursive function
void dectobin(long n);
void main()
{
clrscr();
long n;
cout<<"\n Enter any decimal number :";
cin>>n;
dectobin(n); // calling of function
getch();
}
//definition of recursive function
void dectobin(long n)
 { int r;
if (n<=0) 
 {cout<<"\n Binary Equavalent is :";
return; }
r = n % 2;
dectobin(n/2);
cout<<r;
}


Other 3 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Advanced category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments

9/27/2007 3:11:55 AMRodentor Z. Sano

Very Good! :-)
www.sanosolutions.somee.com
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.