/*WRITE A PROGRAM USING RECURSIVE FUNCTIONS TO GET THE BINARY VALUE FOR THE GIVEN DECIMAL NUMBER*/
#include<stdio.h>
#include<conio.h>
void binary(int x);
main()
{
int num;
clrscr();
printf("Enter number:");
scanf("%d",&num);
printf("The binary value for the given number:\n");
binary(num);
getch();
}
void binary(int x)
{
if(x/2)
binary(x/2);
printf("%d",x%2);
}
#include<stdio.h>
#include<conio.h>
void binary(int x);
main()
{
int num;
clrscr();
printf("Enter number:");
scanf("%d",&num);
printf("The binary value for the given number:\n");
binary(num);
getch();
}
void binary(int x)
{
if(x/2)
binary(x/2);
printf("%d",x%2);
}
output:
Enter number:
25
The binary value for the given number:11001
25
The binary value for the given number:11001
0 comments:
Post a Comment