Decimal to octal conversion using function

Program:

#include<stdio.h>
void dec2oct(int);
int main()
{
int dec;
printf("Enter Positive Integer Number: ");
scanf("%d",&dec);
dec2oct(dec);
return 0;
}
void dec2oct(int m)
{
    int oct[10],i=0,j;
    while(m>0)
    {
    oct[i]=m%8;
    m=m/8;
    i++;
}
for(j=i-1;j>=0;j--)
{
printf("%d",oct[j]);
}
}

Output:



No comments:

Post a Comment

x^y using recursion

Program: #include<stdio.h> int power(int a,int b); int main() { int x,y,ans; printf("Enter x and y:\n "); scanf(...