- 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?

21st Jan 2017, 6:04 PM
haylord
haylord - avatar
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.
21st Jan 2017, 6:10 PM
Rishabh Agrawal
Rishabh Agrawal - avatar