Before attending this lab, you should have read and be familiar with Chapter 5 s
ID: 3933602 • Letter: B
Question
Before attending this lab, you should have read and be familiar with Chapter 5 section 5.1 of Delores Etter's Engineering Problem Solving with C. 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. 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. 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) 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). 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 running sum which is stored in a separate variable called T_sum. 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 = |A - B/B| * 100% (B is the known constant)Explanation / Answer
1. double array[10] = {0};
2. double array[n];
3. for(int i = 0; i < n; i++)
array[i] = 0;
4. double array[n];
int T_sum = 0;
for(int i = 0; i < n; i++)
{
printf("Enter number #%d: ", i+1);
scanf("%d", &array[i]);
T_sum += array[i];
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.