Question

Create a C program that: Within main, declares a

0 0
Add a comment Improve this question Transcribed image text
Answer #1

MinMaxAvg.c

#include <stdio.h>
void arrayStuff(double d[],int size, double *x, double *y, double *z);
int main()
{
double d[10] = {10.5,11.5,12,5,5.5,6.6,7.7,88.8,66.6,55.5};
double min, max, average;
arrayStuff(d,10,&min,&max,&average);
printf("Min value is %lf\n",min);
printf("Max value is %lf\n",max);
printf("Average value is %lf\n",average);
return 0;
}

void arrayStuff(double d[],int size, double *x, double *y, double *z)
{
*x = d[0];
*y = d[0];
int i=0;
double sum = 0;
for(i=0;i <size; i++){
if(*x > d[i]){
*x = d[i];
}
if(*y < d[i]){
*y = d[i];
}
sum = sum + d[i];
}
*z = sum/size;
}

Output:

sh-4.3$ gcc -o main *.c sh-4.3$ main Min value is 5.000000 Max value is 88.800000 Average value is 26.970000 sh-4.3$

Add a comment
Know the answer?
Add Answer to:
Create a C program that: Within main, declares a linear array consisting of 10 double values....
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
  • Write a complete program that: 1) declares two local integers x and y 2) defines a...

    Write a complete program that: 1) declares two local integers x and y 2) defines a global structure containing two pointers (xptr,yptr) and an integer (z) 3) Declares a variable (mst) by the type of previous structure 4) requests the values of x and y from the user using only one scanf statement 5) sets the first pointer in the struct to point to x 6) sets the second pointer in the struct to point to y 7) uses the...

  • Create a program named IntegerFacts whose Main() method declares an array of 10 integers. Call a...

    Create a program named IntegerFacts whose Main() method declares an array of 10 integers. Call a method named FillArray to interactively fill the array with any number of values up to 10 or until a sentinel value (999) is entered. If an entry is not an integer, reprompt the user. Call a second method named Statistics that accepts out parameters for the highest value in the array, lowest value in the array, sum of the values in the array, and...

  • Problem overview. There are a number of ways to normalize, or scale, a set of values....

    Problem overview. There are a number of ways to normalize, or scale, a set of values. One common normalization technique scales the values so that the minimum value goes to 0, the maximum value goes to 1, and the other values are scaled accordingly. Using this normalization technique, the values of the array below are normalized. Original Array Values -1 -2 2 Normalized Array Values 0.25 0.01.0 0.5 The equation that computes the normalized value from a value xe in...

  • C Programming write two functions, similar to what you see in the sample program. The first will ask the user to enter some information (I have included the type in parentheses) First Name (char[]) L...

    C Programming write two functions, similar to what you see in the sample program. The first will ask the user to enter some information (I have included the type in parentheses) First Name (char[]) Last Name (char[]) Age (int) Height in Inches (double) Weight in Pounds (double) You will use pass-by-reference to modify the values of the arguments passed in from the main(). Remember that arrays require no special notation, as they are passed by reference automatically, but the other...

  • Write a program that contains a main function, a “double custom_operator_function(int op_type, double x, double y)”,...

    Write a program that contains a main function, a “double custom_operator_function(int op_type, double x, double y)”, a “double min(double,double)”, a double max(double x,double y), and a double pow(double x, int y). The main function is used to call the custom operator function. Next, the custom operator function calls the min/max/pow functions based on the op_type. From the main, call the custom operator function with the three inputs 1/-3/5, 2/4/5, and 3/4/5. Print the result of each input to screen. i)...

  • ***Please complete the code in C*** Write a program testArray.c to initialize an array by getting...

    ***Please complete the code in C*** Write a program testArray.c to initialize an array by getting user's input. Then it prints out the minimum, maximum and average of this array. The framework of testArrav.c has been given like below Sample output: Enter 6 numbers: 11 12 4 90 1-1 Min:-1 Max:90 Average:19.50 #include<stdio.h> // Write the declaration of function processArray int main) I int arrI6]i int min-0,max-0 double avg=0; * Write the statements to get user's input and initialize the...

  • Three C Code Questions: 5. Write a C program that declares an array of 10 strings,...

    Three C Code Questions: 5. Write a C program that declares an array of 10 strings, each of max length 50 characters, and then reads an entire line of text from the keyboard into each string. 6. Write C code that finds the longest name in this array of strings that you read in Q5. Hint: find the position of the longest string, not the string itself. 7. Write a C program that creates a 4 x 6 two dimensional...

  • Homework Part 1 Write a C program that declares and initializes a double, an int, and a char. You...

    Homework Part 1 Write a C program that declares and initializes a double, an int, and a char. You can initialize the variables to any legal value of your choosing. Next, declare and initialize a pointer variable to each of the variables Using printf), output the following: The address of each of the first three variables. Use the "Ox%x" format specifier to print the addresses in hexadecimal notation The value of each variable. They should equal the value you gave...

  • create a new Java application called "Scorer" (without the quotation marks) that declares a two-dimensional array...

    create a new Java application called "Scorer" (without the quotation marks) that declares a two-dimensional array of doubles (call it scores) with three rows and three columns and that uses methods and loops as follows. Use a method containing a nested while loop to get the nine (3 x 3) doubles from the user at the command line. Use a method containing a nested for loop to compute the average of the doubles in each row. Use a method to...

  • Write a main program that will randomly fill a 2 dimensional array with integer values in...

    Write a main program that will randomly fill a 2 dimensional array with integer values in the range of 0 to 50. Use the Rand_Int function and constants to do this. These values represent the height of a terrain. Write a function that will determine what part of the terrain will flood. A. Create a global constant called MAX and assign it the value of 10. B. Prompt the user in main, at what height do they consider it to...

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
ADVERTISEMENT