Search
 
SCRIPT & CODE EXAMPLE
 

C

recursion to convert decimal to binary

#include <stdio.h>
 
int decimal_binary(int n)
{
    if (n==0)
        return 0;
    else
        return ((n%2)+10*decimal_binary(n/2));
}
 
void main()
{
   int no;
 
   printf("Enter a decimal number
");
   scanf("%d",&no);
   printf("Decimal(%d) = Binary(%d)
",no,decimal_binary(no));
}
Comment

recursion to convert decimal to binary

#include <stdio.h>
 
int decimal_binary(int n)
{
    if (n==0)
        return 0;
    else
        return ((n%2)+10*decimal_binary(n/2));
}
 
void main()
{
   int no;
 
   printf("Enter a decimal number
");
   scanf("%d",&no);
   printf("Decimal(%d) = Binary(%d)
",no,decimal_binary(no));
}
Comment

PREVIOUS NEXT
Code Example
C :: how to print value of pointer in c 
C :: c fork wait for child 
C :: round function in c 
C :: c random array 
C :: why do we need return 0 in c? 
C :: c programing strtok use 
C :: c print multiple variables 
C :: how do you make a copy of a linked list in c 
C :: strong number in c 
C :: C Passing string to a Function 
C :: factorial of a number in c 
C :: add a item to cart woocomerce with quantity 
C :: addition.c 
C :: enable disable audio listener unity 
C :: compare c strings 
C :: c check first character of string 
C :: simple bootstrap form example 
C :: how to call function after some time in vue.js 
C :: link list c 
C :: qtableview get selected row 
C :: c double 
C :: 2d array in c 
C :: what is type casting in c programming 
C :: check if string contains a character in c 
C :: fwrite c 
C :: writing structures in c 
C :: typedef c 
C :: With which of the following can you run code without provisioning or managing servers and pay only for the compute time consumed (there is no charge when the code is not running)? 
C :: modelform prefill with data 
C :: findtotalcurtain 
ADD CONTENT
Topic
Content
Source link
Name
5+8 =