WAP in C to Convert Octal Number into Decimal Number?

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

int main()
{

long int octal, decimal = 0;
int i = 0;
clrscr();
printf(“Enter any octal number: “);
scanf(“%ld”, &octal);
while (octal != 0)
{
decimal = decimal +(octal % 10)* pow(8, i++);
octal = octal / 10;
}
printf(“Equivalent decimal value: %ld”,decimal);
getch();
return(0);
}

Output :-

OctToDec

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s