004-007-006
Enhanced For Loop: Product List Display
Easy
Problem Description
Enhanced For Loop: Product List Display
Learning Objective: Understand how to process arrays concisely using enhanced for loops (for-each)
Overview
Create a program that loops through a string array of product names using an enhanced for loop and displays each product with a number.
Specifications
- Initialize string array
productswith {"Apple", "Banana", "Orange", "Grape"} - Use enhanced for loop to access each element
- Output product number (starting from 1) and product name
Output Format
1: Apple
2: Banana
3: Orange
4: Grape
Note: Enhanced for loops only provide element values, so manage numbering with a separate counter variable.
Ready to Try Running Code?
Log in to access the code editor and execute your solutions for this problem.
Don't have an account?
