Question
Initializing Arrays 2 A loop is often used to initialize an array. Copy the Code Add your Header Comment Save your file as Loop.cpp Compile
Initializing Arrays 2 A loop is often used to initialize an array.
Copy the Code Add your Header Comment Save your file as Loop.cpp Compile and Run your program
#include
-----------------------------------------------------------------------------------
Exercise 1 Code and Run
Code the Pseudocode Save your file as Exercise1.cpp Start num i //array index // Declare a 10 element array Initialize the elements to 0 num numbers[10] = {0,0,0,0,0,0,0,0,0,0} for i = 0 to 9 number[i] = i + 100 Set element at location i equal to i+100 Output each array subscript i and element value numbers[i] end for Stop HINT SAVE your LOOP.cpp as Exercise1.cpp and modify the program to do what the pseudocode requires.
-------------------------------------------------------------------------------------
Exercise 2 Code and Run
Code the psudocode and Save your file as Exercise2.cpp HINT SAVE your Exercise1.cpp as Exercise2.cpp and modify the program to do what the pseudocode requires.
Start num numbers[9] num i //array subscript num numberIn num sum for i = 0 to 8 Ask user to input a number Store number in array[i] element Calculate the sum of the numbers end for Print out the sum Stop
-------------------------------------------------------------------------
Finish coding then compile and run the code below. Modify it to output each loopIndex and each array element. Save our file as Exercise3.cpp Hint save one of your other programs as Exercise3.cpp and modify your declarations, and loop to run the code using the constant NUM_ITEMS
const int NUM_ITEMS = 3; double target [NUM_ITEMS]; int loopIndex; for (loopIndex = 0; loopIndex < NUM_ITEMS; loopIndex++ ) target[loopIndex] = loopIndex + 10;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started