- 1
why would i need to do that
if i put int num = 1; int number; while (num <= 5) { cin >> number; num++ } why would that be useful?
1 Answer
+ 2
This particular example won't be useful that much as the previous four values of "number" you entered will be lost.
Loops are mostly used to store value in an array and perform operation on array.
Hope this helps.