Solution: Print Favorite Numbers

The main() function stores a list of favorite numbers in an array and prints them using a for loop.

  • Declares an integer array favoriteNumbers with 3 elements {7, 21, 42} (these can be changed).

  • Prints the heading "My favorite numbers are:" using cout.

  • Uses a for loop that runs 3 times (i = 0; i < 3; i++), printing each element of the array one by one.

  • The output displays all the numbers stored in the array, each on a new line.

  • Ends with return 0; to signal successful program completion.

Solution: Print Favorite Numbers

The main() function stores a list of favorite numbers in an array and prints them using a for loop.

  • Declares an integer array favoriteNumbers with 3 elements {7, 21, 42} (these can be changed).

  • Prints the heading "My favorite numbers are:" using cout.

  • Uses a for loop that runs 3 times (i = 0; i < 3; i++), printing each element of the array one by one.

  • The output displays all the numbers stored in the array, each on a new line.

  • Ends with return 0; to signal successful program completion.