Like us on google+

Saturday, 19 October 2013

Widgets

PROGRAM TO CONVERT DECIMAL TO BINARY WITHOUT USING ARRAYS.



#include<stdio.h>
void bin(int n);

int main(){

    int n;

    printf("Enter any decimal number: ");

    scanf("%d",&n);
         
           bin(n); 
          
          return 0;
}

 void bin(int n)
{
    if(n/2==0)
   { 
    printf("%d",n%2);
   }
else
  {
   bin(n/2);
   
   printf("%d",n%2);
   
  }
   
   


}
----------------------------------------------------
Sample output
Enter any decimal number:122
1111010
---------------------------------------------------
click on the below link to refer same program without using recursive function.
PROGRAM WHICH CONVERTS DECIMAL TO BINARY WITHOUT USING ARRAYS AND RECURSION.

SHARE THIS POST   

  • Facebook
  • Twitter
  • Myspace
  • Google Buzz
  • Reddit
  • Stumnleupon
  • Delicious
  • Digg
  • Technorati
About us:
Hi guys Sandesh and Rajesh here ... studing engineering in PESIT started this blog as a google contest and also we love blogging ...Hope u like it ...Encourage us by liking us on g+... Any queries dont hesitate to ask Read More →

1 comments: