CJCoding With Joseph
15free / daySign inCreate account

Count the Elements with a Loop

An array called nums has already been created for you with the values {10, 20, 30, 40, 50}. A variable called count has been initialized to 0.

Your task is to use the for loop to count how many elements are in the array by incrementing count once for each element.

This is different from using sizeof: here you are practicing how to count items as you loop through them. Inside the loop, simply add 1 to count each time.

After the loop, print the result in the exact format shown in Expected Output.

Expected Output:

Count: 5

= newline. No newline after the last line.

Hints2 available
Topics:
Arrays
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (cout, fori)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.