post the code where the error occurs...
post the code where the error occurs...
Code:#include <cmath> #include <complex> bool euler_flip(bool value) { return std::pow ( std::complex<float>(std::exp(1.0)), std::complex<float>(0, 1) * std::complex<float>(std::atan(1.0) *(1 << (value + 2))) ).real() < 0; }
can i send you my code via email./. this is my assignment and just in case someone plagiarism .. please
Perhaps you could just post the line that the error refers to and the declaration of the variable or function that is being used.
Sure. I'd love to see it. But if you want a reply, post it here.can i send you my code via email./. this is my assignment and just in case someone plagiarism .. please
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™
Code:#include <stdio.h> void J(char*a){int f,i=0,c='1';for(;a[i]!='0';++i)if(i==81){ puts(a);return;}for(;c<='9';++c){for(f=0;f<9;++f)if(a[i-i%27+i%9 /3*3+f/3*9+f%3]==c||a[i%9+f*9]==c||a[i-i%9+f]==c)goto e;a[i]=c;J(a);a[i] ='0';e:;}}int main(int c,char**v){int t=0;if(c>1){for(;v[1][ t];++t);if(t==81){J(v[1]);return 0;}}puts("sudoku [0-9]{81}");return 1;}
ok here is the problem that occur in my program now....
the day = 29.
the input is of the day is 29Code: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 cout<<"Please enter your date of birth [dd mm yyyy]: "; 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 }
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
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?).Code:int octalDay(int day) { cout.flags(ios_base::oct); return day; }
Code:#include <cmath> #include <complex> bool euler_flip(bool value) { return std::pow ( std::complex<float>(std::exp(1.0)), std::complex<float>(0, 1) * std::complex<float>(std::atan(1.0) *(1 << (value + 2))) ).real() < 0; }
i am sorry but and this is the code here...
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.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 cout<<"Please enter your date of birth [dd mm yyyy]: "; 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 }
can someone point out the problem please...really appreciated
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.
here's a hint, 29 is the decimal form of the octal number 35Originally Posted by peter_hii
>> 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.
you ask a question, you get an answer. you ask the same question, you get another answer. you ask the same question again...what's the point?
1) STATE the problem as clearly as possible
2) READ the responses thoroughly
3) ASK about what you don't understand
4) TRY to solve the problem on your own
5) REPEAT step 2, if necessary
Code:#include <cmath> #include <complex> bool euler_flip(bool value) { return std::pow ( std::complex<float>(std::exp(1.0)), std::complex<float>(0, 1) * std::complex<float>(std::atan(1.0) *(1 << (value + 2))) ).real() < 0; }