+ 2

How to make the user type a value into an Array?

so I made an array of int N[4]; but I don't want to determine the value by default. I want to input it (all 4 elements) by myself when I run the program. I've tried using 'cin' but it doesn't seem to work...

23rd Sep 2016, 5:52 PM
seirz
seirz - avatar
1 Réponse
+ 5
for (int i = 0; i <= 3; i++) cin >> N[i]; With this method you can enter the four digits by: 1 2 3 4 or 1 *return* 2 *return* 3 *return* 4 What ever suits you best.
23rd Sep 2016, 11:22 PM
Cohen Creber
Cohen Creber - avatar