Question
C langauge Please. Complete all of this please. Thanks :)
Statistical Analysis Write a program that creates an array of 10 integers. The program should then use the following function
0 0
Add a comment Improve this question Transcribed image text
Answer #1

C CODE

#include <stdio.h>
#define MAX 10

void getdata(int array[]);
int displaylargest(int array[]);
int displaysmallest(int array[]);
int displayaverage(int array[]);
int displayRange(int array[]);
void sort(int m,int array[]);
int displaymedian( int array[]);
void displayMode(int array[] );

void displaydata(int array[]);

int main() {
int array[MAX];
int largest;
int smallest;
int average;
int range;
float median;
int mode;
  

printf("\nEnter ten numbers \n\n");
getdata(array);
printf("\nThe array elements are :\n" );
displaydata(array);
largest = displaylargest(array);
printf("\nThe largest in array :%d\n", largest);
smallest = displaysmallest(array);
printf("\nThe smallest is array :%d\n", smallest);
average = displayaverage(array);
printf("\nThe average of array element : %d\n", average);
range = displayRange(array);
printf("\nThe Range of array : %d\n", range);
sort (10, array);
median = displaymedian(array);
printf("\nThe Median is : %f\n", median);

displayMode( array );
  

return 0;
}

void getdata(int array[]) {
int x;
printf("Enter a number\n " );
for (x = 0; x<MAX; x++) {
scanf("%d", &array[x]);
}
}

int displaylargest(int array[]) {
int x, largest = array[0];
for (x = 0; x<MAX; x++) {
if (array[x]>largest)
largest = array[x];
}
return(largest);
}

int displaysmallest(int array[]) {
int x, smallest = array[0];
for (x = 0; x<MAX; x++) {
if (array[x]<smallest)
smallest = array[x];
}
return(smallest);
}

int displayaverage(int array[]) {
int x;
int sum = 0;
int average;

for (x = 0; x<MAX; x++) {
sum += array[x];
}
{
average = sum / MAX;
}
return(average);
}

int displayRange(int array[]){
  
int max = displaylargest(array);
int min = displaysmallest(array);
int range = max - min;


return(range);
}

void sort(int m , int array[])
{   
int i, j, t;

for(i = 1; i <= m-1; i++)   
for(j = 1; j <= m-i; j++)   
if(array[j-1] >= array[j])
{
t = array[j-1];
array[j-1] = array[j];   
array[j] = t;
}
printf("\nThe Sorted array is ");
for(i = 0; i < 10; i++)
printf("%4d", array[i]);   
printf("\n");
}
int displaymedian(int array[])
{ int n= 10;
float median;
if ( n % 2 == 0)
median = (array[n/2] + array[n/2+1])/2.0 ;   
else
median = array[n/2 + 1];   
return(median);
}
void displayMode(int Array[])
{

int countArray[MAX];
int modeCount = 0;
int modeNumber;
int i = 0;
int j = 0;

for(i=0; i < MAX; i++)
{
countArray[i] = 0;
}

for(i=0; i < MAX; i++)
{
for (j = 0; j < MAX; j++)
{
if (Array[i] == Array[j])
countArray[i]++;
}
}

for (i=0; i < MAX; i++)
{
if (countArray[i] > modeCount)
{
modeCount = countArray[i];
modeNumber = Array[i];
}   
}


if (modeCount > 1)
printf("\nThe mode of the array is: %d",modeNumber);
else
printf("\nThe mode of the array is: None");
}


void displaydata(int array[]) {
int x;
for (x = 0; x<MAX; x++) {
printf("%d, ", array[x]);
}
}

OUTPUT

I C:\Users\deepa OneDrive\Documents\sample.exe Enter a number Cowo The array elements are : 2, 6, 3, 4, 1, 8, 10, 9, 7, 11, T

 #include <stdio.h> #define MAX 10 void getdata(int array[]); int displaylargest(int array[]); int displaysmallest(int array[]); int displayaverage(int array[]); int displayRange(int array[]); void sort(int m,int array[]); int displaymedian( int array[]); void displayMode(int array[] ); void displaydata(int array[]); int main() { int array[MAX]; int largest; int smallest; int average; int range; float median; int mode; printf("\nEnter ten numbers \n\n"); getdata(array); printf("\nThe array elements are :\n" ); displaydata(array); largest = displaylargest(array); printf("\nThe largest in array :%d\n", largest); smallest = displaysmallest(array); printf("\nThe smallest is array :%d\n", smallest); average = displayaverage(array); printf("\nThe average of array element : %d\n", average); range = displayRange(array); printf("\nThe Range of array : %d\n", range); sort (10, array); median = displaymedian(array); printf("\nThe Median is : %f\n", median); displayMode( array ); return 0; } void getdata(int array[]) { int x; printf("Enter a number\n " ); for (x = 0; x<MAX; x++) { scanf("%d", &array[x]); } } int displaylargest(int array[]) { int x, largest = array[0]; for (x = 0; x<MAX; x++) { if (array[x]>largest) largest = array[x]; } return(largest); } int displaysmallest(int array[]) { int x, smallest = array[0]; for (x = 0; x<MAX; x++) { if (array[x]<smallest) smallest = array[x]; } return(smallest); } int displayaverage(int array[]) { int x; int sum = 0; int average; for (x = 0; x<MAX; x++) { sum += array[x]; } { average = sum / MAX; } return(average); } int displayRange(int array[]){ int max = displaylargest(array); int min = displaysmallest(array); int range = max - min; return(range); } void sort(int m , int array[]) { int i, j, t; for(i = 1; i <= m-1; i++) for(j = 1; j <= m-i; j++) if(array[j-1] >= array[j]) { t = array[j-1]; array[j-1] = array[j]; array[j] = t; } printf("\nThe Sorted array is "); for(i = 0; i < 10; i++) printf("%4d", array[i]); printf("\n"); } int displaymedian(int array[]) { int n= 10; float median; if ( n % 2 == 0) median = (array[n/2] + array[n/2+1])/2.0 ; else median = array[n/2 + 1]; return(median); } void displayMode(int Array[]) { int countArray[MAX]; int modeCount = 0; int modeNumber; int i = 0; int j = 0; for(i=0; i < MAX; i++) { countArray[i] = 0; } for(i=0; i < MAX; i++) { for (j = 0; j < MAX; j++) { if (Array[i] == Array[j]) countArray[i]++; } } for (i=0; i < MAX; i++) { if (countArray[i] > modeCount) { modeCount = countArray[i]; modeNumber = Array[i]; } } if (modeCount > 1) printf("\nThe mode of the array is: %d",modeNumber); else printf("\nThe mode of the array is: None"); } void displaydata(int array[]) { int x; for (x = 0; x<MAX; x++) { printf("%d, ", array[x]); } }
Add a comment
Know the answer?
Add Answer to:
C langauge Please. Complete all of this please. Thanks :) Statistical Analysis Write a program that...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • IN C PROGRAMMING, NOT C++ Rewrite the program you submitted for A8 to use pointers, pointer...

    IN C PROGRAMMING, NOT C++ Rewrite the program you submitted for A8 to use pointers, pointer notation and arithmetic, etc. as follows: If you did not complete A8, you will need to start with those instructions, and then, change your code based on the instructions here The main() function should: Create a fixed or dynamic array, e.g., double grade[SIZE] or double *grade = malloc(...) or calloc(...) Concerning the function call for getData(), pass the address of the array and its...

  • Write a Java program with a single-dimension array that holds 11 integer numbers and sort the...

    Write a Java program with a single-dimension array that holds 11 integer numbers and sort the array using a bubble sort. Next, identify the median value of the 11 integers. Here are the steps your program must accomplish. algorithm (either flowchart or pseudocode) that you will use to write the program Step 1. Create an Place the algorithm in a Word document. 6. Ste the Step 2. Code the program in Eclipse and ensure the following steps are accomplished. 1....

  • In C only Please! This lab is to write a program that will sort an array...

    In C only Please! This lab is to write a program that will sort an array of structs. Use the functions.h header file with your program. Create a source file named functions.c with the following: A sorting function named sortArray. It takes an array of MyStruct's and the length of that array. It returns nothing. You can use any of the sorting algorithms, you would like though it is recommended that you use bubble sort, insertion sort, or selection sort...

  • Please complete the lab following the guidelines using JAVA Activity 1 Write a program called AnalyzeNumbers....

    Please complete the lab following the guidelines using JAVA Activity 1 Write a program called AnalyzeNumbers. This program will have array that holds 10 random integers from 1 to 5. Output the 10 random numbers to the screen using an enhanced for loop. This program will also have a method called frequency that takes an integer array as the parameter and it will return an array that holds the frequency of numbers. Index 0 will hold the frequency of 1,...

  • Rewrite the program you submitted for A8 to use pointers, pointer notation and arithmetic, etc. as...

    Rewrite the program you submitted for A8 to use pointers, pointer notation and arithmetic, etc. as follows: If you did not complete A8, you will need to start with those instructions, and then, change your code based on the instructions here The main() function should: Create a fixed or dynamic array, e.g., double grade[SIZE] or double *grade = malloc(...) or calloc(...) Concerning the function call for getData(), pass the address of the array and its size to pointers; depending on...

  • In Java 2. Array Exercise ( 10 points) Write a Java program that will prompt the...

    In Java 2. Array Exercise ( 10 points) Write a Java program that will prompt the user to input a size of an array. Create an array of type int. Ask a user to fill the array. Create a functions sortArray() and mostFrequency(). The sortArray() function will sort number into incrementing order. The sorting function must be implemented from scratch and it must not use any function from the library. Feel free to use any sorting algorithm. The program will...

  • C programming Strictly - Write a program to sort an array of integers via arrays of...

    C programming Strictly - Write a program to sort an array of integers via arrays of pointers to those integers as shown in the figure. Problem 1 (68 points): Write a program to sort an array of integers via arrays of pointers to those integers as shown in the figure. The code should contain the following functions: 1)to randomly generate an array of integer numbers; 2) to allocate memory and build the arrays of pointers as shown in the figure...

  • JAVA Write a program that prompts the user to enter a file name, then opens the...

    JAVA Write a program that prompts the user to enter a file name, then opens the file in text mode and reads it. The input files are assumed to be in CSV format. The input files contain a list of integers on each line separated by commas. The program should read each line, sort the numbers and print the comma separated list of integers on the console. Each sorted list of integers from the same line should be printed together...

  • Write an object-oriented C++ program (i.e. a class and a main function to use it), using...

    Write an object-oriented C++ program (i.e. a class and a main function to use it), using pointer variables, that program that performs specific searching and sorting exercises of an array of integers. This program has six required outputs. Start by initializing an array with the following integers, in this order: 23, 17, 5, 90, 12, 44, 38, 84, 77, 3, 66, 55, 1, 19, 37, 88, 8, 97, 25, 50, 75, 61, and 49. Your array input may be hardcoded...

  • C languge please ! 1. Using the random number program, fill up an array with 100...

    C languge please ! 1. Using the random number program, fill up an array with 100 random numbers between -30 and 30 and display it. Find out how many of those numbers in the array are positive, negative, even and odd. Display the results. Make sure you cover the special case. Your entire code should have only 1 FOR loop. You will not receive any credit if you use more than 1 loop. (50 points - 5pts for commenting and...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT