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

Write a C program that does NOT employ any Structured Data type like ARRAY OR ST

ID: 3537209 • Letter: W

Question

Write a C program   that does NOT employ any Structured Data type like ARRAY OR STRUCTURE and that will accomplish the following tasks :


(a) Uses a non   recursive validation Function READ_REAL to read in a real value

X iff -99:90 <= X <= +99:90. It MUST REJECT all values of X if it lies outside the

given range with an appropriate message INVALID INPUT GIVE AGAIN and waits

for fresh input. The first proper value of N is passed to main to be used.


(b) Uses the same validation function READ_REAL in another Non Recursive

function READ_POINT to read in the X co-ordinate & Y co-ordinate of a point.

It MUST print the Read In Co-ordinates as well as Return the Read in X & Y

Co-ordinates by two separate pointer parameters.


(c) Then it uses another non recursive Function COMPUTE_ LINE that will accept

as input parameters the co-ordinates of Two end points of a straight Line as has

been read in by the function READ_ POINT, and then computes & RETURNS

the length of that line .



(d) Test ALL the above functions in a single main body. This body employs a loop

to input the co-ordinates of the two end-points of 10 lines using the function

READ _POINT as illustrated above and then computes & print the length of each

line using the function COMPUTE _LINE

Explanation / Answer

please rate - thanks


if you don't normally use getch(); and #include <conio.h> just get rid of me

if any problems, let me know-I will fix them


#include <stdio.h>
#include <conio.h>
#include <math.h>
double READ_REAL();
void READ_POINT(double*,double*);
void TEST_PERFECT(int );
double COMPUTE_LINE(double,double,double,double);
int main()
{double x1,y1,x2,y2;
int i;
for(i=1;i<=10;i++)
{
READ_POINT(&x1,&y1);
READ_POINT(&x2,&y2);
printf("point %d: A line from point (%.2f,%.2f), to point (%.2f,%.2f) is %f units long "
        ,i,x1,y1,x2,y2,COMPUTE_LINE(x1,y1,x2,y2));

}
    getch();
    return 0;
}
double READ_REAL()
{double n;
printf("Enter a number between -99.90 and +99.90: ");
scanf("%lf",&n);
while(n<-99.9||n>99.90)
   {printf("INVALID INPUT GIVE AGAIN ");
   scanf("%lf",&n);
     }
return n;
}
void READ_POINT(double* x,double* y)
{*x=READ_REAL();
*y=READ_REAL();
}
double COMPUTE_LINE(double x1,double y1,double x2,double y2)
{return sqrt(pow(x2-x1,2)+pow(y2-y1,2));
}

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