HI, I nead to write a program that convert an octal number to decimal number, I thought I did it righr but it does'nt work...
I have to use in the first for loop as it is because it is part of the instructions (student homework).
#include <iostream>
#include <math.h>
using namespace std;
void main()
{
double numOfDig, num, newNum;
cout << "Please enter an octal number (base 8): ";
char ch=cin.get();
num=ch-'0';
for (numOfDig=0; ch!='\n' ;numOfDig++)
{
ch=cin.get();
}
I think the main() function needs to be type int rather than a void. Additionally, it should return 0 at the end of your program's execution. So these two steps should allow your program to run:
* changing "void main" to "int main"
* adding "return 0;" after the last line of code (and possibly "cin.ignore();" immediately afterward, assuming your IDE closes automatically when the program is run.)
I hope that helps. Please let me know if there are still any problems. Good luck with your homework!