void OctIn(unsigned int& n);
that reads a base 8 (octal) number and assigns it to n. Use OctIn in a main program that reads the following octal numbers and prints the decimal equivalents:
7, 177, 127, 7776, 177777
#include <iostream>
using std::cin;
using std::cout;
using std::endl;
using std::oct;
void OctIn(unsigned int& n)
{
cin >> oct >> n;
}
int main()
{
unsigned int n;
cout << "Input an octal number: ";
OctIn(n);
cout << n << endl;
return 0;
}
No comments:
Post a Comment