|
|
back to boardDiscussion of Problem 1068. SumWhat's wrong in this? (C++) Posted by pbiiii 15 Feb 2013 14:53 #include <iostream> //where is my mistake? using namespace std; int main() { int number, result; cout << "Enter number: " << endl; cin >> number; result = number; if (number > 0 && number <= 10000) { for (int i = 1; i<number; i++) { result = result + i; } } else if (number <= 0 && number >= -10000) { for (int j = 1; j > number; j--) { result = result + j; } } else { cout << "Enter the number within the limits of [-10000;10000]" << endl; return main(); } cout << "Otvet: " << result << endl; return 0; } Re: What's wrong in this? (C++) Edited by author 25.02.2013 22:28 Re: What's wrong in this? (C++) Posted by Szenti 13 May 2013 20:53 You should not output any other text, only the solution. Re: What's wrong in this? (C++) Posted by stat958 25 Jun 2013 09:27 You shound't cout any extral words! For example : not cout << "Enter number: " << endl; and change cout << "Otvet: " << result << endl; tocout << result << endl; |
|
|