Question

In C programming, Thanks When analyzing data sets, such as data for human heights or for...

In C programming, Thanks

When analyzing data sets, such as data for human heights or for human weights, a common step is to adjust the data. This can be done by normalizing to values between 0 and 1, or throwing away outliers.

For this program, adjust the values by subtracting the smallest value from all the values. The input begins with an integer indicating the number of integers that follow. Assume that the list will always contain less than 20 integers.

Ex: If the input is:

5 30 50 10 70 65

the output is:

20 40 0 60 55

The 5 indicates that there are five values in the list, namely 30, 50, 10, 70, and 65. 10 is the smallest value in the list, so is subtracted from each value in the list.

For coding simplicity, follow every output value by a space, including the last one.

Homework Answers

Answer #1
#include <stdio.h>

int main(){
    int n, i, min;
    int arr[20];
    scanf("%d",&n);
    for(i = 0;i<n;i++){
       scanf("%d",&arr[i]);
       if(i==0){
          min = arr[i];
      }
      if(min > arr[i]){
         min = arr[i];
      }
   }
   for(i = 0;i<n;i++){
      printf("%d ",arr[i]-min);
   }
   return 0;
}

Know the answer?
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
Similar Questions
C++ 19.37 LAB: Adjust list by normalizing - functions When analyzing data sets, such as data...
C++ 19.37 LAB: Adjust list by normalizing - functions When analyzing data sets, such as data for human heights or for human weights, a common step is to adjust the data. This can be done by normalizing to values between 0 and 1, or throwing away outliers. For this program, adjust the values by subtracting the smallest value from all the values. The input begins with an integer indicating the number of integers that follow. Assume that the list will...
c++ 19.36 LAB: Output values below an amount - functions Write a program that first gets...
c++ 19.36 LAB: Output values below an amount - functions Write a program that first gets a list of integers from input. The input begins with an integer indicating the number of integers that follow. Then, get the last value from the input, and output all integers less than or equal to that value. Ex: If the input is: 5 50 60 140 200 75 100 the output is: 50 60 75 The 5 indicates that there are five integers...
(C++) 5.15 LAB: Two smallest numbers with arrays Write a program that reads a list of...
(C++) 5.15 LAB: Two smallest numbers with arrays Write a program that reads a list of integers, and outputs the two smallest integers in the list, in ascending order. The input begins with an integer indicating the number of integers that follow. Ex: If the input is: 5 10 5 3 21 2 the output is: 2 3 You can assume that the list of integers will have at least 2 values. To achieve the above, first read the integers...
Lab Objectives This lab was designed to inforce the following programming concepts: • Using classes to...
Lab Objectives This lab was designed to inforce the following programming concepts: • Using classes to create a data type SimpleCalculator capable of performing arithmetic operations. • Creating const member functions to enforce the principle of least privilege. The follow-up questions and activities also will give you practice: • Using constructors to specify initial values for data members of a programmer-defined class. Description of the Problem Write a SimpleCalculator class that has public methods for adding, subtracting, multiplying and dividing...
Can you write the function in python? def remove_outliers(data, num_outliers): # When analyzing data collected as...
Can you write the function in python? def remove_outliers(data, num_outliers): # When analyzing data collected as a part of a science experiment it # may be desriable to remove the most extreme values before performing # other calculations. Complete this function which takes a list of # values and an non-negative integer, num_outliers, as its parameters. # The function should create a new copy of the list with the num_outliers # largest elements and the num_outliers smallest elements removed. #...
Use Python to Complete the following on a single text file and submit your code and...
Use Python to Complete the following on a single text file and submit your code and your output as separate documents. For each problem create the necessary list objects and write code to perform the following examples: Sum all the items in a list. Multiply all the items in a list. Get the largest number from a list. Get the smallest number from a list. Remove duplicates from a list. Check a list is empty or not. Clone or copy...
Objectives: Model a feedback position control system with Multisim. Study the behavior of the system as...
Objectives: Model a feedback position control system with Multisim. Study the behavior of the system as parameters are adjusted for different types of response. Design Requirements: A closed-loop control system is designed to allow an operator to set a reference angle and the inaccessible controlled element should turn by the same angle. A block diagram of the model is shown below. The gain in the feedback path is −1, and this forces to reach a final steady-state value equal to...
And need to be writing in C++ language Programm need to start with   #include<fstream> Prepare a...
And need to be writing in C++ language Programm need to start with   #include<fstream> Prepare a text file data_in.txt with the following information (highlight the piece of text below with numbers and copy it to a text file): 54, 70, 75, 63, 17, 59, 87, 16, 93, 81, 60, 67, 90, 53, 88, 9, 61, 8, 96, 98, 12, 34, 66, 76, 38, 55, 58, 27, 92, 45, 41, 4, 20, 22, 69, 77, 86, 35, 19, 32, 49, 15,...
Need in C language also need full documentation/explanation of each line A student has established the...
Need in C language also need full documentation/explanation of each line A student has established the following monthly budget: Budget Categories Budgeted amount ----------------------------------------------------- Housing $ 580.00 Utilities $ 150.00 Household Expenses     $ 65.00 Transportation $ 50.00 Food $ 250.00 Medical $ 30.00 Insurance $ 100.00 Entertainment $ 150.00 Clothing $ 75.00 Miscellaneous $ 50.00 ---------------------------------------------------- Write a program that declares a MonthlyBudget structure designed with member variables to hold each of these expense categories. The program should define...
MTH 241 COMMON DATA ANALYSIS ASSIGNMENT (Fall 2018) Previous studies have shown that urban bus drivers...
MTH 241 COMMON DATA ANALYSIS ASSIGNMENT (Fall 2018) Previous studies have shown that urban bus drivers have an extremely stressful job, and a large proportion of drivers retire prematurely with disabilities due to occupational stress. These stresses come from a combination of physical and social sources such as traffic congestion, incessant time pressure, and unruly passengers. In the paper, “Hassles on the Job: A Study of a Job Intervention with Urban Bus Drivers” (Journal of Organizational Behavior, Vol. 20, pp....