Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • 1
    Thanks, but this program is for an assignment, and my teacher's policy is no global constants or variables, so I won't be able to use this. Useful for future reference, though :) Commented May 24, 2016 at 22:59
  • No problem, always glad to help a fellow student! I've modified the code to meet your needs better. PM me if you need help. Commented May 24, 2016 at 23:08
  • It is strange your teacher won't allow global constants - those are safe to use. I've not known a teacher yet to discourage them, even in beginning classes. Certainly global variables are unsafe though, and should rarely be used, if ever. I'd ask for some clarification from your teacher on global constants. Commented May 24, 2016 at 23:13
  • woah woah woah... How did you declare a function inside of Main()? Commented May 24, 2016 at 23:24
  • It's possible (but not recommended) to declare a function inside of main in C++. It's better to declare functions outside of main, so other functions can access each other, but so long as all functions share the same scope, it's okay. Commented May 24, 2016 at 23:28