Question: Please write in programing C Thank you! Question 1: Write a function (named my_add), that has two int parameters, and returns their sum. You must
Please write in programing C Thank you!
Question 1:
Write a function (named "my_add"), that has two int parameters, and returns their sum. You must not write anything besides the function definition (no includes, no declarations, no main function).
Question 2:
Write a program that reads 5 integers from standard in, and write either an O (for an odd) or an E (for an even number) with each character on its own line.
You can create as many functions as you like. However no single function (including main) can have more than 3 semicolons (";") in it. If you violate this rule, you will receive a zero on this assignment.
Example Input:
6
10
3
3
9
Correct Output:
E
E
O
O
O
Question 3:
I'm studying tempertures over various time scales. Unfortunately, my thermometer isn't very precise, so I need to average its readings together to level out the spikes.
I need you to write a program to generate a running average of my temperture data. The first (integer) input is the number of data points (guaranteed to be less than 1000). The next (integer) is the number of data points to be averaging together. The rest of the input are whitespace separated floats. Please output the running average with one point of precision, each on their own line.
Example Input
10 4
27.9 31.7 29.56 35.7 38.5 41.6 50.6 48.6 55.7 60.4
Correct Output:
31.2
33.9
36.3
41.6
44.8
49.1
53.8
Sound familiar? The only difference is now that you know how functions work, you need to use them to solve the problem. I've written the main function and I call two functions that you will need to define, fill_array and calculate_average. You need to define the functions at the location indicated. You may not alter the main function in any way, doing so will result in a zero on this assignment.
For safety, here's a copy of the starter code:
#include
// Define fill_array and calculate_average here.
int main(void) { float values[1000]; int number_of_values, average_length; scanf("%d %d", &number_of_values, &average_length); fill_array(values, number_of_values); for (int start_index = 0; start_index <= number_of_values - average_length; ++start_index) { float average = calculate_average(values, start_index, average_length); printf("%.1f ", average); } return 0; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
