# octal number problem ...

This is a discussion on octal number problem ... within the C++ Programming forums, part of the General Programming Boards category; post the code where the error occurs......

1. post the code where the error occurs...

2. can i send you my code via email./. this is my assignment and just in case someone plagiarism .. please

3. Perhaps you could just post the line that the error refers to and the declaration of the variable or function that is being used.

4. can i send you my code via email./. this is my assignment and just in case someone plagiarism .. please
Sure. I'd love to see it. But if you want a reply, post it here.

Most likely you're trying to assign dec_to_oct() to an integer variable. You can't. (to quote chaosengine) An Int Is An Int Is An Int™

5. ok here is the problem that occur in my program now....

the day = 29.

Code:
```int sqrtOfMonth(double month); //square root of month's function
int numPrimeFactor(int year); //number of prime factors of the year's function
int largestPrimeFactor(int year); //largest prime factor's function
int octalDay(int day); //base 8 representation of the day's function
int sqrDigitLen(int day); //squared digit length of the day's function
string IntToString(int year, int month, int day, int counter); //convert int to string function

int main()
{
int month;
int year, day;
int counter = 0;

//prompt user input
cin>>day>>month>>year;

//display the function from question A - E

cout<<sqrtOfMonth(month)<<endl;
cout<<numPrimeFactor(year)<<endl;
cout<<largestPrimeFactor(year)<<endl;
cout<<octalDay(day)<<endl;

//find the squared digit length

while(day > 10)
{
day = sqrDigitLen(day);
counter++;
}
cout<<counter<<endl;

//display string

string  result = IntToString(year, month, day, counter);
cout << result << endl;

system ("pause");
return 0;
}

int octalDay(int day)
{
cout.flags(ios_base::oct);
return day;
}

//convert integer into string

string IntToString(int year, int month, int day, int counter)
{
ostringstream myStream; //creates an ostringstream object
myStream <<sqrtOfMonth(month)<<numPrimeFactor(year)<<largestPrimeFactor(year)<<octalDay(day)<<counter;

return(myStream.str()); //returns the string form of the stringstream object
}```
the input is of the day is 29
and the output of the first line cout is correct which is 35..

but when i output as string, the numbers turns to 34....

can some one let me know what is the problem please

6. Code:
```int octalDay(int day)
{
cout.flags(ios_base::oct);
return day;
}```
well, to begin with, if you aren't going to pay attention to the answers you've already been given, there isn't much chance you'll benefit from additional advice. second, you don't even provide all of the relevent code needed to pinpoint the problem (what does sqrDigitLen do?).

7. i am sorry but and this is the code here...

Code:
```int octalDay(int day); //base 8 representation of the day's function
string IntToString(int year, int month, int day, int counter); //convert int to string function

int main()
{
int month;
int year, day;
int counter = 0;

//prompt user input
cin>>day>>month>>year;

//display the function from question A - E

cout<<octalDay(day)<<endl;

//display string

string  result = IntToString(year, month, day, counter);
cout << result << endl;

system ("pause");
return 0;
}

int octalDay(int day)
{
cout.flags(ios_base::oct);
return day;
}

//convert integer into string

string IntToString(int year, int month, int day, int counter)
{
ostringstream myStream; //creates an ostringstream object
myStream <<octalDay(day);

return(myStream.str()); //returns the string form of the stringstream object
}```
the output come out from the first cout is what i want which is 35. but when i input into the string, the second cout turns into 29.

can someone point out the problem please...really appreciated

8. ## good luck

isn't that anoying? if what you're trying to do is output a number in textual form, There is no function in c++ for that, sorry. if you want to convert a number to the octal form, then create a function for it. However, you can make a program to change numbers into text, do like a calculator, only deal with one - nine and the different places up to the largest known number which is 999,999,999,999,999 ( or nine-hundred ninty-nine trillion, nine-hundred ninty-nine billion, nine-hundred ninty-nine million, nine-hundred ninty-nine thousand, nine-hundred ninty-nine ). Of course, using this method there's no reason you can't make up numbers and go forever.

9. Originally Posted by peter_hii
i am sorry but and this is the code here...

Code:
```
int octalDay(int day); //base 8 representation of the day's function
string IntToString(int year, int month, int day, int counter); //convert int to string function

int main()
{
int month;
int year, day;
int counter = 0;

//prompt user input
cin>>day>>month>>year;

//display the function from question A - E

cout<<octalDay(day)<<endl;

//display string

string result = IntToString(year, month, day, counter);
cout << result << endl;

system ("pause");
return 0;
}

int octalDay(int day)
{
cout.flags(ios_base::oct);
return day;
}

//convert integer into string

string IntToString(int year, int month, int day, int counter)
{
ostringstream myStream; //creates an ostringstream object
myStream <<octalDay(day);

return(myStream.str()); //returns the string form of the stringstream object
}```
the output come out from the first cout is what i want which is 35. but when i input into the string, the second cout turns into 29.

can someone point out the problem please...really appreciated
here's a hint, 29 is the decimal form of the octal number 35

10. >> the output come out from the first cout is what i want which is 35. but when i input into the string, the second cout turns into 29.