Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

You are preparing for the Boston Marathon. In order to prepare, you need to trai

ID: 674986 • Letter: Y

Question

You are preparing for the Boston Marathon. In order to prepare, you need to train for 10 weeks, running an increasing number of miles per week, starting at running at least 2 miles your first week up to 26 miles by week 10. 1.) Initialize the array with the appropriate number of values.2.) What is the value in the array element when the index contains 2?3.) What is your list length?4.) Calculate the sum of the total miles you spent running over the 10 weeks. Calculate the average number of miles you ran.5.) Write a search to determine whether 4 is on your list.

Explanation / Answer

#include<iostream>
using namespace std;
int main()
{
   int k[10]={2,4,6,8,11,14,17,20,23,26},temp=0,sum=0;
   cout<<" the value at index 2 is : "<<k[2];
   cout << " length of array = " << (sizeof(k)/sizeof(*k)) ;
   for(int i=0;i<10;i++)
   {
       sum+=k[i];
       }  
       float avg=sum/10;
       cout<<" the total miles spent running over the 10 weeks is : "<<sum;
       cout<<" the average number of miles run are : "<<avg;
       for(int i=0;i<10;i++)
   {
       if(k[i]==4)
       cout<<" the value 4 is present in the array at index : "<<i;
   }
  
      
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote