fork download
  1. // ourfunc.cpp -- defining your own function
  2. #include <iostream>
  3. void simon(int); // function prototype for simon() -- This tells the compiler that there is going to be an integer in the simon function? also why void?
  4.  
  5. int main()
  6. {
  7. using namespace std;
  8. simon(3); // call the simon() function -- Is this line assigning integer 3 to simon for use in int n later?
  9. cout << "Pick an integer: ";
  10. int count;
  11. cin >> count;
  12. simon(count); // call it again -- This is assigning whatever input integer user puts in into variable count?
  13. cout << "Done!" << endl;
  14. cin.get();
  15. cin.get();
  16. return 0;
  17.  
  18. }
  19.  
  20. void simon(int n) // define the simon() function -- void? Explanation? Also why does it say int n now instead of count?
  21. {
  22. using namespace std;
  23. cout << "Simon says touch your toes " << n << " times." << endl; // So int n took the input value from count and used it, how?
  24. } // void functions don't need return statements -- Why?
  25.  
Success #stdin #stdout 0s 2856KB
stdin
Standard input is empty
stdout
Simon says touch your toes 3 times.
Pick an integer: Simon says touch your toes -1216786444 times.
Done!