Computers and Technology

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++;

}

}

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 07:00, ayoismeisalex
Our primary purpouse as electricians is to do wich of the following core concepts? a: install electrical components in a way they can be upgraded b: install electrical equiptment in a way that reduces heat c: install electrical systems in a safe manner d: only b and c
Answers: 1
image
Computers and Technology, 23.06.2019 14:30, ahmedeldyame
Select the correct answer. which step can possibly increase the severity of an incident? a. separating sensitive data from non-sensitive data b. immediately spreading the news about the incident response plan c. installing new hard disks d. increasing access controls
Answers: 2
image
Computers and Technology, 23.06.2019 18:30, aalyssag606
This program should be a short piece of code that prints all of the positive integers from 1 to 100 as described more fully below. the program may contain multiple methods, and if using an oo language, should be contained within a single class or object. the program should be designed so that it begins execution when invoked through whichever mechanism is most common for the implementation language. â–ş print out all positive integers from 1 to 100, inclusive and in order. â–ş print messages to standard output, matching the sample output below. â–ş in the output, state whether the each integer is 'odd' or 'even' in the output. â–ş if the number is divisible by three, instead of stating that the number is odd or even, state that the number is 'divisible by three'. â–ş if the number is divisible by both two and three, instead of saying that the number is odd, even or divisible by three; state that the number is 'divisible by two and three'. â–ş design the logic of the loop to be as efficient as possible, using the minimal number of operations to perform the required logic. sample output the number '1' is odd. the number '2' is even. the number '3' is divisible by three. the number '6' is divisible by two and three.
Answers: 1
image
Computers and Technology, 24.06.2019 00:00, babysisjessica1
For the following example of making a peanut butter and jelly sandwich, identify which are inputs, processes, or outputs: bread scooping and spreading peanut butter plate scooping and spreading jelly finished sandwich putting two pieces of covered bread together dirty plate crumbs
Answers: 2
Do you know the correct answer?
Need Help Converting C++ to C code #include

#include

#include

Questions in other subjects:

Konu
Mathematics, 06.07.2021 21:10
Konu
Mathematics, 06.07.2021 21:10
Konu
Mathematics, 06.07.2021 21:10
Konu
Mathematics, 06.07.2021 21:10