Which of the following require saving all the values from standard input (in an
ID: 3542889 • Letter: W
Question
Which of the following require saving all the values from standard input (in an array, say), and which could be implemented as a filter using only a fixed number of variables? For each, the input comes from standard input and consists of N real numbers between 0 and 1.
Print the maximum and minimum numbers.
Print the kth smallest value.
Print the sum of the squares of the numbers.
Print the average of the N numbers.
Print the percentage of numbers greater than the average.
Print the N numbers in increasing order.
Print the N numbers in random order.
Explanation / Answer
please rate - thanks
any questions ask
any better --or do you need code for all of them? that is not a trivial task
Print the maximum and minimum numbers. --can be calculated as number is input -no array
for(i=1;i<=n;i++)
{cin>>n;
if(n>high)
high=n;
if(n<low)
low=n;
}
Print the kth smallest value. --need to save-array
but to do this 1, you need all the numbers(at least k of them), in order to compare them
Print the sum of the squares of the numbers. --can be calculated as number is input -no array
Print the average of the N numbers. --can be calculated as number is input -no array
Print the percentage of numbers greater than the average. --need to save-array
Print the N numbers in increasing order. --need to save-array
Print the N numbers in random order. --need to save-array
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.