C Program convert octal to decimal Number

In this example,we will discuss how to convert octal to decimal number system in the c programming language. Following is the solution to the problem.


Code:

#include <stdio.h>

#include <math.h>

using namespace std;

int main()

{


   int octalNumber,originalnumber;


    printf("Enter a octal number: ");

    scanf("%d", &octalNumber);

  originalnumber=octalNumber;

    int decimalNumber = 0, i = 0, remainder;


    while (octalNumber != 0) 


    {


           decimalNumber += (octalNumber%10) * pow(8,i);

        ++i;

        octalNumber/=10;


    }

     printf("%d in octal = %d in decimal", originalnumber, decimalNumber);


   return 0;

}

Output:

Enter a octal number: 74

74 in octal = 60 in decimal

 

Comments

  1. Good Information


    https://conceptsall.com/how-to-install-windows-10-from-usb/

    ReplyDelete

Post a Comment

Hire a programmer

Hire a programmer

Popular posts from this blog

CSS selector

C Program to convert binary to decimal number

C program to convert decimal to binary number