1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
galina1969 [7]
2 years ago
8

1. Write a program that declares an array named alpha with 50 components of the type double. Initialize the array so that the fi

rst 25 components are equal to the square of the counter (or index) variable and the last 25 components are equal to three times the index variable. 2. Output the array so that exactly ten elements per line are printed. 3. Run your program again, but this time change the code so that the array is filled with random numbers between 1 and 100. 4. Write the code that computes and prints the average of elements of the array. 5. Write the code that that prints out how many of the elements are EXACTLY equal to 100.
Computers and Technology
1 answer:
Aleksandr [31]2 years ago
8 0

Answer:

Explanation:

1. Write a program that declares an array named alpha with 50 components of the type double. Initialize the array so that the first 25 components are equal to the square of the counter (or index) variable and the last 25 components are equal to three times the index variable.  

  double alpha[50];

   for (int i=0;i<25;i++)

   {

       alpha[i]=i*i;

       alpha[i+25]=(i+25)*3;

  }

2. Output the array so that exactly ten elements per line are printed.  

   for (int i=0;i<50;i++)

   {

       cout<<i+1<<". "<<alpha[i]<<" ";

       if (((i+1)%10)==0)

       {

           cout<<endl;

       }

   }

3. Run your program again, but this time change the code so that the array is filled with random numbers between 1 and 100.  

   double alpha[50];

   for (int i=0;i<50;i++)

   {

       alpha[i]=rand()%101;

   }

   for (int i=0;i<50;i++)

   {

       cout<<i+1<<". "<<alpha[i]<<" ";

       if (((i+1)%10)==0)

       {

           cout<<endl;

       }

   }

4. Write the code that computes and prints the average of elements of the array.  

   double alpha[50],temp=0;

   for (int i=0;i<50;i++)

   {

       alpha[i]=rand()%101;

       temp+=alpha[i];

   }

   cout<<"Average :"<<(temp/50);

5. Write the code that that prints out how many of the elements are EXACTLY equal to 100.

   double alpha[50],temp=0;

   for (int i=0;i<50;i++)

   {

       alpha[i]=rand()%101;

       if(alpha[i]==100)

       {

           temp++;

       }

   }

   cout<<"Elements Exacctly 100 :"<<temp;

Please note:  If you put  each of above code to the place below comment  it will run perfectly after compiling

#include <iostream>

using namespace std;

int main()

{

   // If you put  each of above code here it will run perfectly after compiling

   return 0;

}

You might be interested in
Write pseudocode instructions to carry out each of the following computational operations:1. Determine the area of a triangle gi
Zinaida [17]

Answer:

Hi there! The question is checking your knowledge on Pseudocode. Pseudocode is a high level solution written in plain English to outline the steps needed for the program to work correctly. An implementation for the different parts of the question is written below.

Explanation:

1. Determine the area of a triangle

  declare formula for area calculation of triangle as ½ * (base * height)

  validate input parameters “base” and “height”

  apply formula and return result

2. Compute the interest earned Prompt user for input 2

   declare formula for interest calculation as annual interest rate * term *     starting account balance

   validate input parameters “interest_rate” and “starting_account_balance ”

   apply formula and return result as final balance at the end of the year as the interest earned + starting balance.

3. Determine the flying time between two cities given the mileage M between them and the average speed of the airplane.

   declare formula for time calculation of triangle as time = distance / speed

   validate input parameters for mileage “M” and speed “S”

   apply formula and return result

7 0
3 years ago
How do you put a picture when you ask a question?
Setler [38]

Answer:

there should be an option to attach an item. if not try pasting it

Explanation:

5 0
3 years ago
Read 2 more answers
What are some facts about webmasters?
FromTheMoon [43]
Webmasters monitor  the server to be sure  it is  running,Some webmasters decide what kind of  computer will hold a websites information ,Some webmasters abuse other sites by exploiting their comment fields.
4 0
2 years ago
People who work the total hours for which they get paid have
Troyanec [42]
Perfect attendance and a salary
7 0
3 years ago
Read 2 more answers
Which tab should be selected to add a hyperlink within a cell? Home tab Review tab Insert tab Formula tab
Mashcka [7]

Answer:

On the Insert tab

Explanation:

  1. You would select the tab that you want the Hyperlink to be in
  2. select the <em>Insert tab</em>
  3. There you will see a panel that says<em> link</em> press the down arrow than you will see a section that says <em>link</em> again there again you will press the down arrow which will show a option of document you want to add if your looking to add a link form a web browser than at the bottom of the list you will see <em>Insert Link</em>
  4. From there you will see a box pops up there you can upload a file from your computer or PC
  5. Once the box pops up you will enter the web browser page address in the box that says <em>address</em>
  6. From there press <em>okay</em> then your hyperlink will be in the cell you want
  7. If you don't know where or what a web browser address is than on the top of the web browser where you would insert what you are searching all you have to do is press it and it will automatically highlight the text than copy and paste the text by holding <em>Ctrl + C </em>to copy and holding <em>Ctrl + V </em>to paste

6 0
3 years ago
Read 2 more answers
Other questions:
  • How does the team know what to work upon during the iteration
    6·1 answer
  • When you make a pointer variable im C++, is star label a must?
    9·1 answer
  • Which action is LEAST important to maintaining a healthy credit score?
    8·2 answers
  • What sugar is used in a DNA molecule​
    7·2 answers
  • Conversion of a continuous stream of sound into a series of ones and zeroes that can be interpreted by computers results in
    12·1 answer
  • Marie has never used a word processor. In 3 to 4 sentences, describe how she could benefit from using a word processor to comple
    7·2 answers
  • Match the installation type to its description.
    9·1 answer
  • Identify and discuss the seven layers of the Open System Interconnection (OSI) model and their importance on TCP/IP operation.
    7·1 answer
  • What is the BCC feature used for?
    12·2 answers
  • Which of the following are true about algorithms? (You may select more than one)
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!