0

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.

22nd Jan 2017, 7:30 PM
Progress101
Progress101 - avatar
8 Respostas
+ 9
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";
22nd Jan 2017, 8:00 PM
Filip
Filip - avatar
+ 8
Have in mind that you must write std:: for every cin or cout
22nd Jan 2017, 8:04 PM
Filip
Filip - avatar
+ 7
Or just use those objects like this: std::cout std::cin
22nd Jan 2017, 7:44 PM
Filip
Filip - avatar
+ 1
maybe you forgot to include iostream ?
22nd Jan 2017, 7:40 PM
Niels Koomen
Niels Koomen - avatar
+ 1
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.
22nd Jan 2017, 7:42 PM
Progress101
Progress101 - avatar
+ 1
Filip Where would I place those two? Before main or inside? v/r Sherwin Slaughter
22nd Jan 2017, 7:59 PM
Progress101
Progress101 - avatar
+ 1
Filip Gotcha. v/r Sherwin Slaughter
22nd Jan 2017, 8:03 PM
Progress101
Progress101 - avatar
+ 1
Filip Understood. Thank you for the help. v/r Sherwin Slaughter
22nd Jan 2017, 8:06 PM
Progress101
Progress101 - avatar