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

Create an array of 5 integers (any numbers you want). Print each number in the a

ID: 3811022 • Letter: C

Question

Create an array of 5 integers (any numbers you want). Print each number in the array plus 50 Create an array of 5 values of type double. Your program will print the average of all these values. Create an array of 5 integer values. Your program will print the PRODUCT of all numbers in the array. Create a program that asks the user to TYPE 10 integer values of an array. After the user types these numbers, the program will print each number squared. (Use a for loop) Create a program that asks the user to type 5 integer values. After getting the values, your program will then display the consecutive integers whose difference is minimum. For example, if had the following array values: {40, 5, 7, 100, 17} The program would display 5 and 7, since they are consecutive in the array, and since their difference is 2 (the smallest).

Explanation / Answer

7.1)
#include <iostream>
using namespace std;
int main()
{
   int arr[5]={2,3,4,5,6};
       for(int i=0;i<5;i++)
   {
       int sum=0;
       sum = arr[i]+50;
       cout<<sum;
       cout<<endl;
   }
   return 0;
}

7.2)

#include <iostream>
using namespace std;
int main()
{
   double arr[5]={2,3,4,5,6};
   double sum=0;
       for(int i=0;i<5;i++)
   {
       sum = sum+arr[i];
   }
   cout<<"Average:"<<sum/5;
   cout<<endl;
   return 0;
}

7.3)

#include <iostream>
using namespace std;
int main()
{
   double arr[5]={2,3,4,5,6};
   double sum=1;
       for(int i=0;i<5;i++)
   {
       sum = sum*arr[i];
   }
   cout<<"Result:"<<sum;
   cout<<endl;
   return 0;
}

7.4)
#include <iostream>
using namespace std;
int main()
{
   int arr[10];
   int sum=0;
   cout<<"Enter 10 integer values for array:"<<endl;
   for(int i=0;i<10;i++)
   {
       cin>>arr[i];
   }
   for(int i=0;i<10;i++)
   {
       sum=arr[i]*arr[i];  
       cout<<"Square of"<<arr[i]<<":"<<sum;
       cout<<endl;
   }
   return 0;
}

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