Example : (125)10 =(?)8
Solution:
C Program:
#include<stdio.h>
void main()
{ int n,i=0,oct[20];
printf("\nEnter a Decimal no.");
scanf("%d",&n);
while(n>0)
{ oct[i]=n%8;
n=n/8;
i++;
}
printf("\nEquivalent Octal no. is: ");
for(--i;i>=0;i--)
printf("%d",oct[i]);
}
Output:
Solution:
C Program:
#include<stdio.h>
void main()
{ int n,i=0,oct[20];
printf("\nEnter a Decimal no.");
scanf("%d",&n);
while(n>0)
{ oct[i]=n%8;
n=n/8;
i++;
}
printf("\nEquivalent Octal no. is: ");
for(--i;i>=0;i--)
printf("%d",oct[i]);
}
Output:
Enter a Decimal no. 125
Equivalent Octal no. is: 175
No comments:
Post a Comment