Friday, May 25, 2012

C Program That Convert Any Binary Number To Octal Number


Hello friends how are you?enjoying your life or not?today i'm sharing an interesting program with all of you,coding is very simple and you can easily understand it.If you think that this code is little bit long than share another code with me.




#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int number,sum=0,rem,x,n,arr[100],i,j;
clrscr();
printf("\n\n\n Enter any binary number:");
scanf("%d",&n);
number=n;
x=0;
while(number!=0)
{
rem=number%10;
sum=sum+(rem*pow(2,x));
x++;
number=number/10;
}
i=0;
while(sum!=0)
{
arr[i]=sum%8;
i++;
sum=sum/8;
}
printf("\n\n\n Octal number of binary number %d is:",n);
for(j=i-1;j>=0;j--)
printf(" %d",arr[j]);
getch();
}









Thanks Friends>>>>>>

No comments:

Post a Comment

Please Give Me Your Views

Popular Posts