Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Could you please help me? Thanks! Answer the questions below in a typed document

ID: 3729038 • Letter: C

Question

Could you please help me? Thanks! Answer the questions below in a typed document, numbered appropriately. Print out this sheet as a cover page. Bring the completed assignment to your next lab class. 1) Write a declaration statement for an array with 10 elements. Assume that the array is going to contain double-precision floating-point temperature data in units of Kelvins. Initialize the array with values of 0 in all elements. 2) Write the same declaration, but for an array with n elements, where n is a pre-declared integer variable (In other words, has already been declared in advance.) Do not give the array initial values in this case. (You cannot initialize variable-length arrays in a declaration statement) 3) Write a for loop that will run a total of n times, and in each iteration will set one of the elements of your temperature array to zero. (Remember that arrays in c go from subscript (0) to (n-1) 4) Write a for loop that will run a total of n times, and in each iteration will ask the user for an input value and will store it in a different element of your temperature array. It should also feature a statement that adds the new element to a runnng sum which is stored in a separate variable called T_sum. 5) Write a statement that calculates the percent error between a variable containing an average measured temperature and a defined symbolic constant containing the boiling point of an unspecified substance Percent Error = |-| * 100% (B is the known constant)

Explanation / Answer

Answer 1:

#include<stdio.h>

int main()

{

double temp[10] = {0}; // {0} initializes all 10 elements of array to value 0 because we have fixed size array

return 0;

}

------------------------------------------------------------------------------------------------------------------------

Answer 2:

#include<stdio.h>

int main()

{

int n = 50;

double temp[n]; // declared array for n elements

return 0;

}

------------------------------------------------------------------------------------------------------

Answer 3:

#include<stdio.h>

int main()

{

int n = 50;

double temp[n]; // declared array for n elements

for(int i=0; i<n; i++) // run loop from i =0 to i < n i.e; it will run till value i = n-1

temp[i] = 0;

return 0;

}

-------------------------------------------------------------------------------------------------------------

Answer 4:

#include<stdio.h>

int main()

{

int n = 50;

double temp[n]; // declared array for n elements

double T_sum = 0;

for(int i=0; i<n; i++)

{

printf("Enter temprature: ");

scanf("%lf", &temp[i]); // ask user for input and store it in current indexed ithlocation

T_sum = T_sum + temp[i]; // add value of current ith value into T_sum

}

return 0;

}

-----------------------------------------------------------------------------------------

Answer 5:

#include<stdio.h>

#include<math.h>

int main()

{

int n = 50;

double temp[n]; // declared array for n elements

double T_sum = 0, A, percent_error;

const double B = 50; // B is declared as symbolic constant value

for(int i=0; i<n; i++)

{

printf("Enter temprature: ");

scanf("%lf", &temp[i]); // ask user for input and store it in current indexed ithlocation

T_sum = T_sum + temp[i]; // add value of current ith value into T_sum

}

A = T_sum/n; // A is avg temprature

  percent_error = (abs(A-B)/B) * 100;

printf("Percent error is %lf ",percent_error);

return 0;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote