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)
1
Expert's answer
2013-02-07T08:16:27-0500
#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"); }
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot
Comments
Leave a comment