62 478
Assignments Done
98,8%
Successfully Done
In June 2018

Answer to Question #23786 in C++ for EMMANUEL

Question #23786
write a program which inputs an octal number and outputs its decimal equivalent. the following example illustrates the expected behaviour of the program:
input an octal number : 214
octal(214) = Decimal (532)
Expert's answer
#include <iostream>

void main(){
int oct0, oct, dec = 0, a = 1, r, t = 1;
std::cout<<"enter an octal number: ";
std::cin>>oct;
oct0 = oct;
while (oct0 != 0)
{
r = oct0%10;
oct0 = oct0/10;
dec += t*r;
t *= 8;
a++;
}
std::cout<<"octal("<<oct<<") = decimal("<<dec<<")\n";
system("pause");
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions