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
A program written in a(n) procedural language consists of sequences of statements that manipulate data items. __________________
Alenkasestr [34]

Answer:

true.

Explanation:

According to my research on information technology, I can say that based on the information provided within the question the statement is completely true. Procedural programming is a widely used paradigm that basically gives the program a set of routines or specifications, and the program mixes and matches them as they continuously repeat the process. It is used in many areas, including video game development.

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

7 0
3 years ago
What directs the read/write arm of the hard drive to where data exists and accesses it upon the user's request?
Nastasia [14]

Answer:

NTFS (New Technology File System) or FAT(File Allocation Table) are used to direct read/write arm of hard drive to where data exists and access it upon user's request

Explanation:

Both NTFS and FAT are used but NTFS is fast and optimal and superseed the FAT and supported by windows NT 3.1 and later versions.  

7 0
3 years ago
In Broadbent's filter model of attention, the stages of information processing occur in which order?
victus00 [196]

Answer:SENSORY STORE, FILTER, DETECTOR, STM.

Explanation:Donald Broadbent in 1958 stated one of the earliest theory of attention,he stated that physical features of messages are used to select one message for further processing and that all others are lost.This differs from inattentional blindness, which is when you focus hard on something and fail to notice unexpected things entering your visual area. He believes that

Information from all of the stimuli presented at any given time enters a sensory buffer with unlimited capacity.

3 0
3 years ago
Hello! I am a new coder, so this is a simple question. But I am trying to create a code where you enter a number, then another n
slavikrds [6]

no longer returns an error but your math seems to have something wrong with it, always returns 0

Console.WriteLine("Enter a percentage here");

   int Percent = int.Parse(Console.ReadLine());

   Console.WriteLine("Enter your number here");

   int Number = int.Parse(Console.ReadLine());

   int result = Percent / 100 * Number;

6 0
2 years ago
Some 3d printers work by controlling the exact locations where a liquid
kow [346]
Were a liquid what? id doesn't make any sense.
6 0
3 years ago
Other questions:
  • "what is the name of the ipsec configuration file"
    9·1 answer
  • We can see spreadsheet results graphically by creating:
    15·1 answer
  • At an uncontrolled intersection, you should yield to the car on the right. True or false.
    10·2 answers
  • Given that two int variables, total and amount, have been declared, write a sequence of statements that: initializes total to 0
    14·1 answer
  • PHP is based on C rather than ______.
    5·1 answer
  • Implement a recursive method named power that takes 2 integer parameters named base and expo. The method will return the base ra
    6·1 answer
  • Which of the following is a quick way to restore the arrow pointer after you have used it for drawing?
    5·1 answer
  • Write a program named split_me.py that accepts a string in the format Age.FirstName and returns the value FirstName is Age years
    14·1 answer
  • What is a computer class from 8​
    12·1 answer
  • Cybersecurity is defined as the set of techniques to protect the secrecy, integrity, and availability of computer systems and da
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!