Assignment Error | SoloLearn: Learn to code for FREE!


Assignment Error

Just starting working with Cpp this month. In the middle of working on a hailstone assignment. Earlier I had no problem with the main function when it was just: int main(). I remember needing to review assignment requirements again, and noticed the professor wants us to use: int main (int argc, char** argv) instead of what I provided earlier. Once I made that change It get errors about cin, cout, and endl haven't been declared in this scope. _______________________________________________________ #include <cstdio> using namespace std; //Function Variable Declaration. int hailstone_Sequence(int n); int lengthof_Sequence(int l); //void Print_Set(int [] set, int size); int main(int argc, char** argv) { int user_Input; cin >> user_Input; (error) cout << "What number shall I start with? " << user_Input << endl; (error) cout << "The hailstone of sequence starting at " << user_Input << " is: " << hailstone_Sequence(user_Input) << endl; cout << "The length of the sequence is ___. \n"; //cout << "The largest number in the sequence is: " << \n"; cout << "The longest hailstone sequence with a number up to __ has length ___ "; cout << "The longest hailstone sequence with a number up to __ begins with ___ "; return 0; } __________________________________________________________ Can someone provide some insight? Appreciate the help.

1/22/2017 7:30:35 PM


8 Answers

New Answer


Whenever you use cout for example if you want to print hello somewhere, instead of 'using namespace std' which you would write at the top, after #include stuff, you just write: std::cout<<"Hello";


Have in mind that you must write std:: for every cin or cout


Or just use those objects like this: std::cout std::cin


maybe you forgot to include iostream ?


Gotcha. I'll try to do that. I originally had iostream in, but he wanted us to use a template to start off that didn't have that. Could be a oversight on the professor's part, not sure. But I'll give it a shot. Thank you.


Filip Where would I place those two? Before main or inside? v/r Sherwin Slaughter


Filip Gotcha. v/r Sherwin Slaughter


Filip Understood. Thank you for the help. v/r Sherwin Slaughter