08 Jun devry comp122 week 6 homework
Question
COMP122
Week 6 Homework
Complete the following problems.
1. Write C++ statements to do the following:
a. Declare an array alpha of 15 components of type int.
b. Output the value of the 10th component of the alpha array.
c. Set the value of the 5th component of the alpha array to 35.
d. Set the value of the 9th component of the alpha array to the sum of the 6th and 13thcomponents of the alpha array.
e. Set the value of the 4th component of the alpha array to three times the value of the 8th component minus 57.
f. Output alpha so that five components appear on each line.
2. What is stored in the list array after the following code executes?
int list[5];
for(int j = 0; j < 5; j++)
{
list[j] = 2 * j + 5;
if (j % 2 == 0)
{
list[j] = list[j] – 3;
}
}
3. What does array index out of bounds mean? What can happen if this occurs in your program?
4. Write C++ statements to define and initialize the following arrays using appropriate data types:
a. An array of heights has 6 components which have the following values: 5.5, 5.8, 6.3, 6.6, 4.9, 5.9.
b. An array of weights has 4 components which have the values: 140, 165, 190, 207.
c. An array of symbols which contains the following characters: ‘$’, ‘%’, ‘@’, ‘!’, ‘|’, ‘&’.
d. An array of the seasons which contains “Spring”, “Summer”, “Fall”, “Winter”.
5. Given the following declaration, what is stored in the 8th element of the array?
int list[10] = {1, 2, 3, 4, 5};
6. When an array is passed as an actual parameter to a function, what is really being passed in to the function? Why are arrays passed this way?
7. Write a for loop to initialize the following array (int data[10]) with the values 10, 9, 8… 1.
8. Given an array of 10 doubles named data, write a loop that loads the array with user input.
9. Given an array of 100 doubles named data, write a loop that creates the sum of all the array elements.
10. Write a loop that finds the smallest element in an integer array called data containing 100 elements.
Our website has a team of professional writers who can help you write any of your homework. They will write your papers from scratch. We also have a team of editors just to make sure all papers are of HIGH QUALITY & PLAGIARISM FREE. To make an Order you only need to click Ask A Question and we will direct you to our Order Page at WriteDemy. Then fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.
Fill in all the assignment paper details that are required in the order form with the standard information being the page count, deadline, academic level and type of paper. It is advisable to have this information at hand so that you can quickly fill in the necessary information needed in the form for the essay writer to be immediately assigned to your writing project. Make payment for the custom essay order to enable us to assign a suitable writer to your order. Payments are made through Paypal on a secured billing page. Finally, sit back and relax.
About Writedemy
We are a professional paper writing website. If you have searched a question and bumped into our website just know you are in the right place to get help in your coursework. We offer HIGH QUALITY & PLAGIARISM FREE Papers.
How It Works
To make an Order you only need to click on “Order Now” and we will direct you to our Order Page. Fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.
Are there Discounts?
All new clients are eligible for 20% off in their first Order. Our payment method is safe and secure.
