C PROGRAM:
#include<stdio.h>
void get_array(double x[],int npts)
{
int i;
double d;
printf("Enter %d elements: ",npts);
for(i=0;i<npts;i++)
{
scanf("%lf",&d);
x[i]=d;
}
}
void display_array(double x[],int npts)
{
int i;
for(i=0;i<npts;i++)
{
printf("%.2lf ",x[i]);
}
}
double array_max(double x[25],int npts)
{
int i;
double max=x[0];
for(i=1;i<npts;i++)
{
if(max<x[i])
max=x[i];
}
return(max);
}
double array_min(double x[25],int npts)
{
int i;
double min=x[0];
for(i=1;i<npts;i++)
{
if(min>x[i])
min=x[i];
}
return(min);
}
void norm(double x[25],int npts)
{
int i;
double d;
double min,max;
min=array_min(x,npts);
max=array_max(x,npts);
for(i=0;i<npts;i++)
{
d=x[i];
d=(d-min)/(max-min);
x[i]=d;
}
}
int main()
{
int npt;
double x[25];
printf("Enter number of elements (less than 25): ");
scanf("%d",&npt);
if(npt>=0 && npt<=25)
{
get_array(x,npt);
printf("\nArray elements before normalisation\n");
display_array(x,npt);
norm(x,npt);
printf("\nArray elements after normalisation\n");
display_array(x,npt);
}
else
printf("\nEntered size is not in range");
}
OUTPUT:

Problem overview. There are a number of ways to normalize, or scale, a set of values....
Create a C program that: Within main, declares a linear array consisting of 10 double values. You can assign values to the array when it is declared or fill them items manually using scanf () - your choice. Also, declare three doubles: min, max, and average. Then from within main, a function is called. The function should take a pointer to the array declared above and then finds the maximum value, the minimum value, and calculates the average of the...
In this problem you'll get to use one of Java's random number generators, java.util.Random (see the docs for Random). This class generates a random double precision number uniformly distributed in the range [0.0 ... 1.0). That is, the numbers go from 0 to 1, including 0 but excluding 1. It is a common need in Java programming to generate a random integer number that's uniformly distributed in the range of [0 ... n), such as we saw in the dice...
Exercise #1:Write a C program that contains the following steps. Read carefully each step as they are not only programming steps but also learning topics that explain how numeric arrays in C work.Write a while loop to input a series of numbers (either from a file or from the keyboard, but using a file will make for easier debugging) into a one dimensional array of type double named x_arr, declared to be 25 elements in length. Count the elements as you...
***The following is to be written in C:****
****The following is the sizeof.c program that needs to be
modified:****
****Section B11 the question asks to refer to:****
Modify the sizeof.c program (in the sizeof folder on github) and show the data range (min and max) in addition to the size of the data types in a nice table (print one line for each data type). Refer to section B11 in your textbook (page 257) for getting min and max values...
2. Pointer arithmetic: a) Write a printString function that prints a string (char-by-char) using pointer arithmetics and dereferencing. b) Write a function “void computeMinMax(double arr[], int length, double * min, double * max)” that finds the minimum and the maximum values in an array and stores the result in min and max. You are only allowed to use a single for loop in the function (no while loops). Find both the min and the max using the same for loop....
For this c++ assignment, Overview write a program that will process two sets of numeric information. The information will be needed for later processing, so it will be stored in two arrays that will be displayed, sorted, and displayed (again). One set of numeric information will be read from a file while the other will be randomly generated. The arrays that will be used in the assignment should be declared to hold a maximum of 50 double or float elements....
I should use the array and loop to create a java program
according to the instruction, but I have no idea how to do
it.
Introduction This lab assignment continues to give you practice using loops, particularly loops with variable termination conditions, and it also provides you an opportunity to use one-dimensional arrays. Recall that an array is used to store a collection of data. The data can be values of Java primitive data types or else objects (for instance,...
a) Write a function called print_doubles that prints the first n elements of an array of doubles. Assume the array is long enough. Example: double v[5] = {1,2,3,4,5}; print_doubles(v, 5); // prints [1,2,3,4,5] b) Write a function with the following signature: void get_min_max(const double values[], int n, double *pmin, double *pmax); that returns in output parameters *pmin the value of the minimum element in array values and in *pmax the maximum element. Parameter n represents the size of array values....
Q.1. Create a C++ class template called ArrayCalc, to perform a series of mathematical operations on an array. These mathematical operations are calculating the minimum, maximum, sum and average values of the array. The ArrayCalc class template accepts one type parameter, which can be defined as: template <class T>. This allows ArrayCalc to carry out operations for different array data types. ArrayCalc has the following public methods, described here in pseudo code: i. void FindMin(inArrayData[], inArraySize, SoutMinVal); (This function accepts...
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...