Problem:
To convert the given decimal no into octal without using in build function ,Example 26 shoule printed as 32
Solution:
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,intex[]={0,1,2,3,4,5,6,7},data[100],i=0,j;
clrscr();
printf("\n enter the no ..");
scanf("%d",&a);
printf("\nthe %d to octal is ",a);
while(a!=0)
{
data[i]=a%8;
i++;
a=a/8;
}
for(i--;i>=0;i--)
{
j=data[i];
printf("%d",intex[j]);
}
getch();
}
Output:
To convert the given decimal no into octal without using in build function ,Example 26 shoule printed as 32
Solution:
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,intex[]={0,1,2,3,4,5,6,7},data[100],i=0,j;
clrscr();
printf("\n enter the no ..");
scanf("%d",&a);
printf("\nthe %d to octal is ",a);
while(a!=0)
{
data[i]=a%8;
i++;
a=a/8;
}
for(i--;i>=0;i--)
{
j=data[i];
printf("%d",intex[j]);
}
getch();
}
Output:
No comments:
Post a Comment