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
7. Malware could A. cause a system to display annoying pop-up messages B. be utilized for identity theft by gathering personal i
beks73 [17]

Answer:

D

Explanation:

Malware can be used for many things, a click of a button can send complete access to the attacking system. Malware comes in all formes and powers.

4 0
2 years ago
: Each individual data items of record is called a
musickatia [10]
Each individual data items of record is called field (letter A).
The client may communicate with Proxy server to use a protocol to proxy the communication between the client and the DBMS. Proxy servers lets you hide your real Ip address and replaces it with a new IP obtained from proxy server sites.

6 0
3 years ago
In order to prevent unauthorized access, how can the shadow file be configured to enforce a password policy?​ What happens to ac
NemiM [27]

Answer : The securtiy of the password can be maitained by the shadow files such as:-

  • max is for the days that represent that the same password can be used without the need for changing it  
  • min is for the days that represent waiting days before the changing of password after he/she gets a new password
  • warn are the days that come with Waring sign that the password is going to expire soon.

For a certain period of time , the user can access the log in when the password has expired . If that period is timed out then there will be no log in option and the account gets disabled.

4 0
2 years ago
Given two 3x3 arrays of integer, x1 and x2, write the code needed to copy every value from x1 to its corresponding element in x2
Reika [66]

Answer:

#include<iostream>

#include<iomanip>

using namespacestd;

int main ()

{

int x1[3][3]={1,2,3,4,5,6,7,8,9};

int x2[3][3];

int i,j;

for(i=0;i<3;i++)

for(j=0;j<3;j++)

x2[i][j] = x1[i][j];

cout<<"copy from x1 to x2 , x2 is :";

for(i=0;i<3;i++)

for(j=0;j<3;j++)

cout<<x2[i][j]<<" ";

cout<<endl;

system("pause");

return 0;

}

/* Sample output

copy from x1 to x2 , x2 is :1 2 3 4 5 6 7 8 9

Press any key to continue . . .

*/

Explanation:

5 0
3 years ago
Using functions,
ZanzabumX [31]

Answer:

See explaination

Explanation:

#include <iostream>

using namespace std;

int main()

{

double h, w;

int s, a, b;

cout<<"height in feet: ";

cin>>h;

cout<<"width in feet: " ;

cin>>w;

cout<<"tile size in inches:";

cin>>s;

int height = h*12;

if(height%s==0)

a = height/s;

else

a = height/s + 1;

int width = w*12;

if(width%s==0)

b = width/s;

else

b = width/s + 1;

cout<<"Number of tiles: "<<a*b;

}

8 0
3 years ago
Other questions:
  • Playville is a tiny town in fictional middle earth, which is inhabited by dwarves and elves. Playville has a playground to which
    6·1 answer
  • Categories of functions specified by computer instruction?
    11·1 answer
  • If you want to import text into a DTP application that was first created in a word processing program, what must you do?
    9·2 answers
  • What is required to control access to the file system using file and folder permissions on a windows based computer?
    8·1 answer
  • A style manual can be described as
    11·2 answers
  • A golf ball is at rest on the grass. What must happen to cause the ball to move?
    5·1 answer
  • When can we feel electricity?? Tell me the volt
    15·1 answer
  • Drawing programs typically create images using mathematical formulas, instead of by coloring pixels, so images can be resized an
    12·1 answer
  • Computer privacy typically occurs when which of the following is violated?
    6·1 answer
  • can i get an access code for free online? if yes, what website is it so i can get a free access code?​
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!