subject

Need Help Converting C++ to C code #include

#include

#include

#include

#include

#include

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=200;

srand(time(NULL));

// Creating array dynamically

int* nos = new int[size];

//Calling the functions

fillArrayWithRandNos(nos, size);

displayArray(nos, size);

cout<<"Mean :"< 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 =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:"<

int cnt=0;

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

{

cout<

cnt++;

}

cout<<"Displaying the histogram :"<
cnt=0;

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

{

cout<
for(int j=0;j
{

cout<<"*";

}

cout<
cnt++;

}

}

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 15:30
Why would a programmer use the logical operator and in an if statement? a: when an action is to be taken that requires both conditions to be falseb: when an action is to be taken that requires both conditions to be truec: when an action is to be taken that requires the first condition to be falsed: when an action is to be taken that requires the second condition to be truei took the test and the answer is b.
Answers: 3
question
Computers and Technology, 22.06.2019 23:00
Suppose s, t, and w are strings that have already been created inside main. write a statement or statements, to be added to main, that will determine if the lengths of the three strings are in order by length, smallest to largest. that is, your code should determine if s is strictly shorter than t, and if t is strictly shorter than w. if these conditions hold your code should print (the boolean value) true. if not, your code should print false. (strictly means: no ties) example: if s, t, and w are "cat", "hats", and "skies" your code should print true - their lengths are 3-4-5; but if s, t, and w are "cats" "shirt", and "trust", then print false - their lengths are 4-5-5 enter your code in the box below
Answers: 2
question
Computers and Technology, 23.06.2019 00:30
If joey was single and his taxable income was $9,500, how much would he pay in taxes each year?
Answers: 1
question
Computers and Technology, 23.06.2019 09:30
The place where the extended axis of the earth would touch the celestial sphere is called the celestial
Answers: 1
You know the right answer?
Need Help Converting C++ to C code #include

#include

#include

Questions
question
English, 13.03.2021 06:30
question
History, 13.03.2021 06:30
question
History, 13.03.2021 06:30
question
Mathematics, 13.03.2021 06:30
question
Mathematics, 13.03.2021 06:30
question
Mathematics, 13.03.2021 06:30
Questions on the website: 13722362