Recent Posts

9-latest-250px-course

Write a C program to Convert Octal to Decimal number

Write a C program to Convert Octal to Decimal number



Program:-     

#include <stdio.h>

#include <math.h>

long int octal_to_decimal(int octal)
{
int decimal = 0, i = 0;

while(octal != 0)
{
decimal += (octal%10) * pow(8,i); // multiplying with powers of 8
++i;
octal/=10;  // Divide by 10 to make it as decimal
}

i = 1;

return decimal;
}

int main()
{
int octal;

printf(“\nEnter an octal number: “);
scanf(“%d”, &octal);

printf(“\nDecimal Equivalent : %d\n”,octal_to_decimal(octal));

return 0;
}

Output:-

....
SHARE

Milan Tomic

Hi. I’m Designer of Blog Magic. I’m CEO/Founder of ThemeXpose. I’m Creative Art Director, Web Designer, UI/UX Designer, Interaction Designer, Industrial Designer, Web Developer, Business Enthusiast, StartUp Enthusiast, Speaker, Writer and Photographer. Inspired to make things looks better.

  • Image
  • Image
  • Image
  • Image
  • Image
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment