#include<conio.h>
#include<stdio.h>
main()
{
do
{
clrscr();
int numb[10];
int flag=9;
int counter=0;
int check[9];
printf("Enter any number ");
scanf("%d",&numb[0]);
for(int a=0; flag>1; a++)
{
if(numb[a]%2==0)
{
check[a]=0;
numb[a+1]=numb[a]/2;
flag=numb[a]/2;
counter++;
}
else if(numb[a]%2==1)
{
check[a]=1;
numb[a+1]=numb[a]/2;
flag=numb[a]/2;
counter++;
}
}
counter--;
printf("\n1");
for(a=counter; a>=0; a--)
{
printf("%d",check[a]);
}
printf("\n\nDo you want to run this program again (y/n) ? ");
}
while(getche()!='n');
printf("\n\nThank You for using this program");
getche();
}
#include<stdio.h>
main()
{
do
{
clrscr();
int numb[10];
int flag=9;
int counter=0;
int check[9];
printf("Enter any number ");
scanf("%d",&numb[0]);
for(int a=0; flag>1; a++)
{
if(numb[a]%2==0)
{
check[a]=0;
numb[a+1]=numb[a]/2;
flag=numb[a]/2;
counter++;
}
else if(numb[a]%2==1)
{
check[a]=1;
numb[a+1]=numb[a]/2;
flag=numb[a]/2;
counter++;
}
}
counter--;
printf("\n1");
for(a=counter; a>=0; a--)
{
printf("%d",check[a]);
}
printf("\n\nDo you want to run this program again (y/n) ? ");
}
while(getche()!='n');
printf("\n\nThank You for using this program");
getche();
}
No comments:
Post a Comment