C program to convert Octal number to Decimal Number

Simple C program to convert Octal number to Decimal Number

Code:

#include <stdio.h>
#include<conio.h>
#include <math.h>

int main()
{
long long octal, tempOctal, decimal;
int rem, place;
printf("Enter any octal number: ");
scanf("%lld", &octal);
tempOctal = octal;
decimal = 0;
place = 0;

while(tempOctal!=0)
{
rem = tempOctal % 10;
decimal += pow(8, place) * rem;
tempOctal /= 10;

place++;
}

printf("\nOctal number = %lld\n", octal);
printf("Decimal number = %lld", decimal);

getch();
}

Comments

Popular posts from this blog

C program to evaluate Prefix Expression using Stack data structure

Java Program to Implement sorting algorithm using TCP on Server application

C++ program to perform data transformation Min-max and Z score Normalization