Question
In C there are 10 errors in this code please identify them: //suppress deprecation warnings: #define _CRT_SECURE_NO_DEPRECATE 1 #define _CRT_NONSTDC_NO_DEPRECATE 1 #include //printf(), scanf() #include
In C there are 10 errors in this code please identify them: //suppress deprecation warnings: #define _CRT_SECURE_NO_DEPRECATE 1 #define _CRT_NONSTDC_NO_DEPRECATE 1 #include //printf(), scanf() #include //getch() #include //sqrt() #define NUM_TESTS 14 #define STEP 0.1 #define START_VAL 0.4 //function prototype: double approx_sqrt(double fX); int main(void) { double fVal; = START_VAL; //input value needs semi double fApp; //result of approx sqrt double fLib; //result of library sqrt char sYourName[] = ("Sherlock Holmes"); //string containing your name double iCount; //loop counter printf("Test approximate square root function... "); /* print table headings */ printf("Input Val Approx Sqrt Library Sqrt Difference "); printf("----------------------------------------------------- "); /* generate values */ for(iCount = 1b; iCount <= NUM_TESTS; iCount++) { printf("%8.4f", fVal); fApp = approx_sqrt(fVal); if(fApp != 0.0) { fLib = sqrt(fVal); printf("%14.4d%14.4f", fApp, fLib); printf("%14.2f%% ", 100.0 * (fApp - fLib) / fApp); } //endif fVal += STEP; //update value to test } //endfor printf(" This program was debugged by: "); printf("\t%s ", sYourName); printf(" Press any key to exit..."); getch(); return 0; } } //end program //---------------------------------------------------------------------- //function definition: double approx_sqrt(double fX); { double fY; if(fX >= 0.49 && fX <= 1.51) //this line has no bugs { fY = 0.375 + 0.75*fX - 0.125*fX*fX; //this line has no bugs } else if { printf(" Input value out-of-range! "); fY = 0.0; } //endifelse return fY; } //endapprox_sqrt
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started