I got an error, this is my program:- /******************************************
ID: 3827354 • Letter: I
Question
I got an error, this is my program:-
/********************************************************/
/* */
/* MAIN PROGRAM */
/* */
/********************************************************/
#include <stdio.h>
FILE *inptr, *outptr;
const float PI = 3.14159;
const float E = 30E06;
const int NUM = 7;
void fninput(float *, float *, float *);
void fncompute(float, float, float, float *, float *, float *);
void fnoutput(float, float, float, float, float, float);
int main ( )
{
int count = 0;
float load, diam, length;
float stress, strain, elong;
inptr = fopen("proj5in.dat", "r");
outptr = fopen("proj5out.dat", "w");
while(count < NUM)
{
fninput(&load, &diam, &length);
fncompute(load, diam, length, &stress, &strain, &elong);
fnoutput(load, diam, length, stress, strain, elong);
count = count + 1;
}
return 0;
}
/********************************************************/
/* */
/* INPUT FUNCTION */
/* */
/********************************************************/
void fninput(float *p, float *d, float *l)
{
fscanf(inptr, "%f %f %f", p, d, l);
}
/*
/********************************************************/
/* */
/* SURAFCE AREA OF A CYLINDER CALCULATION */
/* */
/********************************************************/
void fncompute(float p, float d, float l, float *st, float *str, float *eln)
{
float area;
area = PI * (d * d) / 4.0;
*st = PI / area;
*str = *st / E;
*eln = l / *str;
}
/********************************************************/
/* */
/* OUTPUT FUNCTION */
/* */
/********************************************************/
void fnoutput(float p, float d, float a, float l, float st, float str, float elng)
{
fprintf(outptr,"%12.2f %6.2f %5.2f ", p, d, l);
}
Explanation / Answer
try lf instead of f and you should write
fscanf(inptr,"%lf %lf %lf",&p,&d,&l);
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.