I wrote a program to calculate the hypotenuse of a right triangle with two different methods. I'm supposed to do it ten different times but my question is: How do I make it so I can input 10 different sets of numbers in the same window without it saying "Press any key to continue..." after I input the first set of numbers? If that makes any sense...
You could leave off the "Press any key to continue." just use // to comment out that line. :)
I believe he was joking.
Yes it does. You would accomplish this by using what are called loops. There is the while loop, for loop and do while loop http://www.cplusplus.com/doc/tutorial/control/ . What loops essential do is run a section of code repeatedly until a exit condition evaluates to true.
For this problem you could create a index number that you can use as a counter for a while loop. Basically every time the loop goes through a iteration the index should increase by one. Then the while loop condition can be set to not run the loop once the 10th iteration is complete.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
// This will be our index.
int index = 0;
// This is saying run the loop as long as index does not equal 10
while (index != 10)
// This is where you put the code you want to run 10 times
// Make sure to increase the index at the end of each loop.