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

Hi I got to while fscanf but stuck. Would you please help? I will grade asa life

ID: 3629880 • Letter: H

Question

Hi I got to while fscanf but stuck. Would you please help? I will grade asa life saver.

Thank you in advance!
#include


#include
#include

Hi I got to while fscanf but stuck. Would you please help? I will grade asa life saver. Thank you in advance! Manufacturing engineers use three principal measures of the roughness of the surface of an object. All are based on measurements at evenly spaced intervals along the surface. Values above the centerline are positive; values below the centerline are negative. The three roughness indicators are given below. The Arithmetic mean value (Ra) equals the sum of the absolute values of the surface heights divided by the number of values in the sum. where a, b, c, etc. are the measurements at intervals a, b, c, etc., and n is the number of measurements. The Root-mean square average (Rq) equals the square root of the sum of the squares of the surface heights divided by the number of values in the sum. where a, b, c, etc. are the measurements at intervals a, b, c, etc., and n is the number of measurements. The Maximum roughness height equals the height difference from the level of the deepest trough to the highest peak. Write a program that takes the surface measurements from the input file surface.txt (which you create) and computes and displays these three surface roughness indicators.1 The output file should contain a listing of the input data (6 values per line), and the values of the 3 surface roughness indicators, nicely formatted. Sample file surface.txt -4.1 -2.2 -0.5 1.2 3.3 4.6 5.1 2.1 0.2 -3.6 -4.1 0.2 0.5 2.2 4.1 -0.2 -1.2 -3.3 -4.6 -5.0 -2.2 -1.1 0.8 3.2 -0.1 -4.8 Share: by email on facebook on twitter

Explanation / Answer

#include #include #define n = 26 int main() { FILE *fin; fin = fopen("surface.txt" "r"); if ( fin == NULL ) { printf( "error opening input file. "); system("pause"); exit(1); } FILE *fout; fout = fopen("surface.out", "w"); if ( fout == NULL ) { printf( "error opening output file. "); system("pause"); exit(1); } double i, Ra, Rq, num; while(fscanf (fin, "%lf", &num) == 1);