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]
3 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]3 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
How to make the heart symbol in photoshop
sveta [45]
Click the font drop-down box in the tool settings bar. Select "Arial." 6. Press "Alt-3" using your keyboard number pad's "3" key to insert the heart symbol<span>.</span>
3 0
3 years ago
Read 2 more answers
When studying an information system, illustrations of actual documents should be collected using a process called _____.
Oliga [24]
<span>When studying an information system, illustrations of actual documents should be collected using a process called sampling. Correct answer: D
</span>This process systematically selects representative elements of a population with the goal to get representative and useful information about the population as a whole and it is useful when <span>data sets that are too large to efficiently analyze in full.</span>
6 0
3 years ago
Dr. Joon asks her students how to insert a table in an Excel workbook. The students record the steps a chart. Which students lis
Leona [35]

Answer:

C

Explanation:

Both Table and Format as Table can be used to create a table

4 0
3 years ago
Mike recently started using Google Display Ads to create a more automated approach to managing his campaigns. What's one automat
Marysya12 [62]

Answer:

Automated targeting

Explanation:

Display Automated Targeting is an automated targeting option within the Audience settings of the display campaigns that gives Google full right to show your ads to an audience that is “similar” to the one you specified.

8 0
3 years ago
if you want to exclude a portion of an image which option should be chosen?? A. Arrange B. Position C. Crop D. Delete
Anuta_ua [19.1K]
It would be C- crop. This allows you to specifically delete parts of the image using drag and drop features. Hope this helps!
3 0
2 years ago
Other questions:
  • Compare and contrast the TwoFish encryption algorithm with the DES and AES algorithms. In your comparison be sure to compare and
    6·1 answer
  • You are using a crimper to attach an RJ-45 connector to a Cat 6 UTP cable. You need to use the T568A standard to connect the ind
    6·1 answer
  • One of the original forms of viruses, is usually stored on some form of removable media. When the removable media is connected t
    9·1 answer
  • which of these paste options is commonly available from the paste options button? A&gt; use the destination them. B. keep the em
    14·2 answers
  • Minimalism is a major movement in postmodern art. O True O False
    14·1 answer
  • You receive $50 as a birthday gift and choose to spend it all on new wallpaper for your room. The opportunity cost of this decis
    7·1 answer
  • In the early part of labor, contractions come every
    6·1 answer
  • Create a function named first_a that uses a list comprehension. The function will take a single integer parameter n. Find every
    13·1 answer
  • You have a small company and want to keep your costs low, but it is important your employees share data. Which network would pro
    5·2 answers
  • A ____ is someone who develops programs and apps or writes the instructions that direct the computer or mobile device to process
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!