Tuesday, March 5, 2024

40. Octal to Decimal :—

 40. Octal to Decimal :—


#include<stdio.h>

int main()

{

    int i,sum,n,r;

    printf("enter a value of n ");

    scanf("%d",&n);

    i=1;

    sum=0;

    while(n>0)

    {

        r=n%10;

        sum=sum+i*r;

        n=n/10;

        i=i*8;

    }

    printf("%d",sum);

    return 0;

}


No comments:

Post a Comment