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
The command to delete all the files that have filenames that starts with letter c or c and ends with a letter z or z is
dimaraw [331]
The command is : <span>rm [Aa]*[Zz] </span>
4 0
3 years ago
Adding Web pages helps Web designers ___. Choose all answers that are correct.
ss7ja [257]

Answer:

B

Explanation:

7 0
2 years ago
2) A ________ uses electronic memory and has no motors or moving parts. A) mechanical hard drive B) solid-state drive C) Blu-ray
grin007 [14]

Answer:

A.mechanical hard

Explanation:

brainliest me and follow ty

7 0
2 years ago
(1) Prompt the user for an automobile service. Output the user's input. (1 pt) Ex: Enter desired auto service: Oil change You en
Pavlova-9 [17]

Answer:

In Python:

#1

service = input("Enter desired auto service: ")

print("You entered: "+service)

#2

if service.lower() == "oil change":

   print("Cost of oil change: $35")

elif service.lower() == "car wash":

   print("Cost of car wash: $7")

elif service.lower() == "tire rotation":

   print("Cost of tire rotation: $19")

else:

   print("Invalid Service")

Explanation:

First, we prompt the user for the auto service

service = input("Enter desired auto service: ")

Next, we print the service entered

print("You entered: "+service)

Next, we check if the service entered is available (irrespective of the sentence case used for input). If yes, the cost of the service is printed.

This is achieved using the following if conditions

For Oil Change

<em>if service.lower() == "oil change":</em>

<em>    print("Cost of oil change: $35")</em>

For Car wash

<em>elif service.lower() == "car wash":</em>

<em>    print("Cost of car wash: $7")</em>

For Tire rotation

<em>elif service.lower() == "tire rotation":</em>

<em>    print("Cost of tire rotation: $19")</em>

Any service different from the above three, is invalid

<em>else:</em>

<em>    print("Invalid Service")</em>

<em></em>

6 0
3 years ago
Visit the target Let Me Discover page and review the history of HTML. Also, search the internet for the history of the internet
Lyrx [107]

Whether you are a novice, hoping to delve into the world of web design or an experienced webmaster keen to improve your skills, we’ve got online tutorials tailored to your web design needs.


Our HTML For Absolute Beginners will turn you from wannabe to webmaster in just a few hours. Unlike many other HTML tutorials, it's a step-by-step guide – not a boring long-winded reference.


Our step-by-step guide teaches you the basics of HTML and how to build your first website. That means how to layout an HTML page, how to add text and images, how to add headings and text formatting, and how to use tables.

use this because that is cheating no offence

3 0
3 years ago
Other questions:
  • How to remove a channel from favorite list on suddenlink?
    15·1 answer
  • When the increment or decrement operator is placed before the operand (or to the operand's left), the operator is being used in
    6·1 answer
  • Security awareness training can reduce the risk of a data breach by what percentage?
    12·1 answer
  • The trim video feature allows you to trim your clip by time measurements that are accurate to ____ of a second.
    5·1 answer
  • What is the function of the capsid? it allows a virus to live independently. it is composed of genetic material. it destroys the
    12·2 answers
  • Name the sections of an instruction.
    15·1 answer
  • Write a programme with C++ language wich print the biggest number in between three numbers , whith INT
    14·1 answer
  • Plzz help.... <br><br>i will mark u as brainliest if u answer correct
    10·1 answer
  • What is connected to the base unit in Desktop PC?
    14·1 answer
  • 1. The supervisory software of a computer is called _____ (a) operating system (b) high – level language (c) transistor
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!