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
A stack is initially empty, then the following commands are performed: push 5, push 7, pop, push 10, push 5, pop, which of the f
MatroZZZ [7]

Answer:

d

Explanation:

6 0
3 years ago
Do you agree with the EU's decision that people should be able to ask Google to remove search results that contain incorrect, un
AnnyKZ [126]

Answer: Yes

Explanation: One should not be able to just find negative information on someone just because they googled it (unless they're famous of course)

7 0
3 years ago
Read 2 more answers
Consider the following statements: struct supplierType { string name; int supplierID; }; struct paintType { supplierType supplie
Romashka [77]

Answer:

The answer is "supplierType"

Explanation:

Description of the code:

  • In the given program two structure is defined, that is "supplierType and paintType", in which "supplierType" structure two-variable name and "supplierID" is defined, that datatype is "String and integer".
  • In the next step, "paintType" is declared, in which "supplierType" object supplier is created, in which two string variable "color and paintID" are defined, in which "supplierType" data type is supplied.
3 0
3 years ago
And<br>Why the computer is called dilligent<br>Versatile machine?give long answer ​
WITCHER [35]

Answer:

The answer to this question is given below in this explanation section.

Explanation:

"Why the computer is called diligent

Versatile machine"

Computer is called versatile machine because it is used in almost all the fields for various purposes.Because it can perform the task repeatedly without loosing its speed and accuracy for a long time.They are versatile because they can be used for all sorts of task.They can also do many of the same tasks in different ways.Computer is the electronic device which perform the logical and mathematical calculation.Computer is known as the  versatile machine because it is very fast in every field and its part of life without it was cannot imagine life.

It can do the work faster and in every field the computer is used for making their work faster.

It can perform the work fast so it is called versatile machine.

Advantages of versatile machine:

  • Computer are very fast due to which thousand of job can be performed within the short period of time.
  • Complex mathematical problems and logical operations can be solved by using this computer.
  • As computer is versatile device,multiple task like communication,graphics,documentation can be done.

Disadvantages of versatile machine:

  • Computers are machine hence they have no brain so they work according to the program instruction set inside it.
  • It is an electronic deice and it uses electronic sources to work,So it is very risk to store data and information on the computer independently because some electric and electronic damages may damage the data.So we have to make regular backup of the data.

5 0
2 years ago
Plz answer all the questions :)
AURORKA [14]

Answer:

is there multiple choice or do i have to answer from my own words??

7 0
3 years ago
Other questions:
  • What runs a network, steering information between computers and managing security and users?
    11·1 answer
  • What is the next series of dragon ball super
    6·2 answers
  • Jeremy is designing a website for a florist. He intends to discuss the web design with his client. Which tool should Jeremy use
    6·1 answer
  • What function would you use to find the mean in a Microsoft excel document ?
    6·2 answers
  • What is the purpose of the .NET Framework Class Library? a. it provides pre-written code that can be used by .NET applications b
    13·1 answer
  • You just bought a hard drive, you plan on using this a secondary storage, once installed, what needs to be done to the drive and
    6·1 answer
  • Which of the following is the definition of registration authority ( RA)?
    10·1 answer
  • Type the correct answer in the box. Spell all words correctly.
    13·1 answer
  • ---------------------- use of the Internet to access programs and data on computers that are not owned and managed by the user o
    9·1 answer
  • Atheel tests a program and gets a NameError. How can this be fixed?
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!