- 2

Fill in the blanks to use the enhanced for loop for an array called"arr"

int total =0; for (int x_ ____ ){ total+=x;}

22nd Mar 2017, 11:35 AM
MICHAEL Gicheri
11 Answers
+ 23
: arr
22nd Mar 2017, 2:39 PM
Jafca
Jafca - avatar
+ 2
int total =0; for (int x:arrayname){ total+=x;}
22nd Mar 2017, 11:44 AM
Meharban Singh
Meharban Singh - avatar
+ 2
I dont know arrayname,hence I wrote arrayname
22nd Mar 2017, 12:14 PM
Meharban Singh
Meharban Singh - avatar
+ 2
Good way to learn questions you don't understand fully. The enhanced for-loop iterates over the an array, List, Set .... It copies the next element every iteration into the variable you specified. Hope that helps 😎
22nd Mar 2017, 12:26 PM
Thomas Zenglein
Thomas Zenglein - avatar
+ 2
int total=0; for (int x: arr) { total+=x; }
23rd May 2022, 2:49 PM
Vallari Prashanth
Vallari Prashanth - avatar
0
post it in questions :-)
22nd Mar 2017, 11:44 AM
Meharban Singh
Meharban Singh - avatar
0
the answer is not that big
22nd Mar 2017, 12:08 PM
MICHAEL Gicheri
0
int total = 0; for(int x:arr) { total += x; }
29th Aug 2017, 1:25 AM
Pallavi D S
Pallavi D S - avatar
- 1
x:arr
11th Jun 2020, 4:15 AM
chathura jayawardhana
- 2
: arr
19th May 2020, 4:01 PM
vikram yadav
- 3
ilove u
24th Sep 2019, 11:42 AM
Jeroben Taña
Jeroben Taña - avatar