Problem 1: A set of numbers x(i) in the range x(low) to x(high) can be "normalized" into a new range min to max, by calculating each
normxi from each x(i) as follows:
normx(i) = min + (x(i) - x(low)) * (max - min) / x(high) - x(low)
Write a complete C program to read from a data file an integer count (between 3 and 20) and two real numbers (min and max).
Then read the set of real numbers (there are count numbers) for xi into an array. Normalize the xi values into the range min to max, placing the normalized values into a second array. Finally print the original and normalized values in a two-column table, with appropriate column headings.
Use the following sets of data to test your program. Put all three high-resolution screenshots in your report.
7 0.0 10.0 67.9 45.2 33.3 66.1 83.5 14.3 50.5
11 0.0 1.0 6.9 4.2 3.3 6.1 8.5 1.3 5.5 9.9 8.0 3.6 2.8
5 0.0 100.0 -34.3 50.9 0.0 43.2 -77.7
Problem 2:. It is incomplete as it lacks the definition of the get_min_range function.
Complete the get_min_range function to make the program work to sort the array specified in the main program.
#include <stdio.h>
#define ARRAY_SIZE 8
// finds the position of the smallest element in the subarray
// list[first] through list[last].
// Pre: first < last and elements 0 through last of array list are defined.
// Post: Returns the subscript k of the smallest element in the subarray;
// i.e., list[k] <= list[i] for all i in the subarray
int get_min_range (int list[], int first, int last)
{
/* complete the function here */
}
// sorts the data in array list
void
select_sort(int list[], int n)
{
int fill, /* index of first element in unsorted subarray */
temp, /* temporary storage */
index_of_min; /* subscript of next smallest element */
for (fill = 0; fill < n-1; ++fill) {
/* Find position of smallest element in unsorted subarray */
index_of_min = get_min_range (list, fill, n-1);
/* Exchange elements at fill and index_of_min */
if (fill != index_of_min) {
temp = list[index_of_min];
list[index_of_min] = list[fill];
list[fill] = temp;
}
}
}
int
main (void) {
int array[] = {67, 98, 23, 11, 47, 13, 94, 58};
int i;
select_sort (array, ARRAY_SIZE);
for (i=0; i < 8; ++i)
printf ("%d", array[i]);
return (0);
Problem 3:. Write the program by completing the main function
that calls the push function at least three three times, then prints
out the updated stack, then calls the pop function and prints out
the updated stack again.
#include <stdio.h>
#define STACK_EMPTY '0'
#define STACK_SIZE 20
void
push(char stack[], /* input/output - the stack */
char item, /* input - data being pushed onto the stack */
int *top, /* input/output - pointer to top of stack */
int max_size) /* input - maximum size of stack */
{
if (*top < max_size-1) {
++(*top);
stack[*top] = item;
}
}
char
pop (char stack[], /* input/output - the stack */
int *top) /* input/output - pointer to top of stack */
{
char item; /* value popped off the stack */
if (*top >= 0) {
item = stack[*top];
--(*top);
} else {
item = STACK_EMPTY;
}
return (item);
}
int
main (void)
{
char s [STACK_SIZE];
int s_top = -1; // stack is empty
/* complete the program here */
return (0);
}
Write code in above commented area and post on below comment section. If you need any support then contact Us:
realcode4you@gmail.com