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
Ipatiy [6.2K]
3 years ago
8

C++

Computers and Technology
1 answer:
nikitadnepr [17]3 years ago
8 0

Answer:

Check the explanation

Explanation:

<u>The Code</u>

#include <fstream>

#include <iostream>

#include <cmath>

#include <cstring>

#include <cstdlib>

#include <ctime>

using namespace std;

//Function Declarations

void fillArrayWithRandNos(int nos[],int size);

void displayArray(int nos[],int size);

double mean(int nos[],int size);

double variance(int nos[],int size);

double median(int nos[],int size);

int mode(int nos[],int size);

void histogram(int nos[],int size);

int main() {

  //Declaring variables

const int size=100;

srand(time(NULL));

 

// Creating array dynamically

int* nos = new int[size];

 

//Calling the functions

fillArrayWithRandNos(nos,size);

displayArray(nos,size);

cout<<"Mean :"<<mean(nos,size)<<endl;

cout<<"variance :"<<variance(nos,size)<<endl;

cout<<"Median :"<<median(nos,size)<<endl;

cout<<"Mode :"<<mode(nos,size)<<endl;

histogram(nos,size);

 

  return 0;

}

void fillArrayWithRandNos(int nos[],int size)

{

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

  {

      nos[i]=rand()%(45) + 55;

  }

}

void displayArray(int nos[],int size)

{

  cout<<"Displaying the array elements :"<<endl;

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

  {

      cout<<nos[i]<<" ";

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

      cout<<endl;

  }

}

double mean(int nos[],int size)

{

  double sum=0;

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

  {

      sum+=nos[i];

  }

  return sum/size;

}

double variance(int nos[],int size)

{

  double avg=mean(nos,size);

 

double variance,sum=0;

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

{

sum+=pow(nos[i]-avg,2);

}

//calculating the standard deviation of nos[] array

variance=(double)sum/(size);

return variance;

}

double median(int nos[],int size)

{

      //This Logic will Sort the Array of elements in Ascending order

  int temp;

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

{

for (int j = i + 1; j < size; j++)

{

if (nos[i] > nos[j])

{

temp = nos[i];

nos[i] = nos[j];

nos[j] = temp;

}

}

}

 

int middle;

float med;

middle = (size / 2.0);

if (size % 2 == 0)

med = ((nos[middle - 1]) + (nos[middle])) / 2.0;

else

med = (nos[middle]);

return med;

}

int mode(int nos[],int size)

{

  int counter1 = 0, counter2, modevalue;

for (int i = 0; i < size; i++) {

counter2 = 0;

for (int j = i; j < size; j++) {

if (nos[i] == nos[j]) {

counter2++;

}

if (counter2 > counter1) {

counter1 = counter2;

modevalue = nos[i];

}

}

}

if (counter1 > 1)

return modevalue;

else

return 0;

}

void histogram(int nos[],int size)

{

  int hist[9]={0};

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

  {

      if(nos[i]>=55 && nos[i]<=59)

      {

      hist[0]++;

      }

      else if(nos[i]>=60 && nos[i]<=64)

      {

      hist[1]++;

      }

      else if(nos[i]>=65 && nos[i]<=69)

      {

      hist[2]++;

      }

      else if(nos[i]>=70 && nos[i]<=74)

      {

      hist[3]++;

      }

      else if(nos[i]>=75 && nos[i]<=79)

      {

      hist[4]++;

      }

      else if(nos[i]>=80 && nos[i]<=84)

      {

      hist[5]++;

      }

      else if(nos[i]>=85 && nos[i]<=89)

      {

      hist[6]++;

      }

      else if(nos[i]>=90 && nos[i]<=94)

      {

      hist[7]++;

      }

      else if(nos[i]>=95 && nos[i]<=99)

      {

      hist[8]++;

      }

  }

     

  cout<<"Displaying the count of numbers in each interval:"<<endl;

 

      int cnt=0;

  for(int i=55;i<=99;i+=5)

  {

  cout<<i<<"-"<<i+4<<"|"<<hist[cnt]<<endl;

 

      cnt++;

  }

 

  cout<<"Displaying the histogram :"<<endl;

  cnt=0;

  for(int i=55;i<=99;i+=5)

  {

  cout<<i<<"-"<<i+4<<"|";

  for(int j=0;j<hist[cnt];j++)

  {

      cout<<"*";

  }  

      cout<<endl;

      cnt++;

  }          

     

 

 

}

#########

___________________________

The output can be seen in the attached image below.

You might be interested in
If it is impractical to place guest users in a secure network, isolated from the production network by firewall barriers, then:
IgorLugansk [536]

Answer:

specific areas of access should be determined and they should be as restrictive as possible.

Explanation:

According to my research on security features of networks , I can say that based on the information provided within the question then specific areas of access should be determined and they should be as restrictive as possible. This would provide the highest level of security while still allowing production to be smooth.

I hope this answered your question. If you have any more questions feel free to ask away at Brainly.

7 0
3 years ago
Which of the following is not true about managing your privacy settings? (select all that apply)
Evgesh-ka [11]
I'm going with 
<span>The things that you post online become public information.
and
</span><span>Employers screen job candidates based on social medias.

Because when you post online, you can very easily make your account private, or only share the post to a specified group of people.

Employers also screen job candidates based on their backround, personality, etc.</span>
4 0
3 years ago
Read 2 more answers
In addition to regular watch features, which two features are often found on smart watches?
andriy [413]
Phone capabilities and fitness monitoring
5 0
3 years ago
Which of the following function declarations correctly expect an array as the first argument?
NARA [144]

Answer:

Only

Option: void f1(float array[], int size);

is valid.

Explanation:

To pass an array as argument in a function, the syntax should be as follows:

functionName (type arrayName[ ] )

We can't place the size of the array inside the array bracket (arrayName[100]) as this will give a syntax error. The empty bracket [] is required to tell the program that the value that passed as the argument is an array and differentiate it from other type of value.

3 0
3 years ago
The unthinkable happens and disaster strikes, crippling your network. You implement your disaster plan, but it doesn't go smooth
Degger [83]

Answer:

Post-mortem.

Explanation:

It refer to the discussion or analysis of event like here disaster why it doesn't work like plan based and through whole discussions what we learn so in future avoid such type of issue or mistakes.

7 0
3 years ago
Other questions:
  • Pedestrians, cyclists, horse drawn vehicles and wheel chair users are known as ___________
    6·2 answers
  • Nathan wants to create multiple worksheet containing common formatting styles for his team members. Which file extension helps h
    5·1 answer
  • Which option allows you to view slides on the full computer screen?
    11·1 answer
  • Once you resize a photograph, it cannot be returned to its original size. TRUE or FALSE
    8·1 answer
  • In his article “is google making up stupid” Nicholas Carr uses a metaphor to suggest that
    11·2 answers
  • A network that typically reaches a few meters, such as up to 10 meters (33 feet), and consists of personal devices such as mobil
    14·1 answer
  • Which of these is one of the primary concerns for protecting your family when online?
    9·2 answers
  • What is the simplest way to permanently get rid of an unwanted file?
    9·1 answer
  • . What type of computer implementation does the following code represent? Load A,10 Load B,1:5 Add A,B STORE A, [20]
    5·1 answer
  • PLS HEEELLLP ASAP, DONT JOKE
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!