Sunday, July 19, 2020

Decimal to Octal

Decimal to Octal:
=============
#include<stdio.h>
#include<conio.h>
void main()
{
    int decimal,octal[20],i,temp,j;
    printf("Enter decimal value");
    scanf("%d",&decimal);
    
    i=0;
    
    top:
    
    octal[i]=decimal/8;
    temp=decimal/8;
    if (temp>0)
    {
        decimal=temp;
        i++;
        goto top;
    } 

    printf("Octal value of given decimal is: \n");
    for(j=i;j>=0;j--)
    {
        printf("%d",octal[j]);
    }
getch();
}

No comments:

Post a Comment

Octal to Decimal Conversion

Octal to Decimal Conversion ===================== void main() { int dec,i,j; long int octal; clrscr(); printf("Enter binary val...