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

Purpose: Process a stream of data. Use loops & conditional statements Descriptio

ID: 3637785 • Letter: P

Question

Purpose: Process a stream of data.
Use loops & conditional statements

Description:

Create a C program that reads in a stream of integer pairs,
each representing an (x,y) pair in the cartesian coordinate
system. For each successive pair of integers, display the
distance and direction traveled from one pair to the next.

You can assume that in each successive pair only one value
changes, so that travel is always right, left, up, or down.

{This would be like the locations displayed in the tracker.c
example from the "Conditional Statements" section in
Polzin's online notes (the x, y values.) }

Also, keep a running total of the distance between each pair
of points and determine the distance between the
initial/starting point and the final/finish point.

Ex:
--
Data:
0 0
0 3
4 3
2 3
2 2

Output:
0 0 <- Start
0 3 <- Distance: 3 Direction: Up
4 3 <- Distance: 4 Direction: Right
2 3 <- Distance: 2 Direction: Left
2 2 <- Distance: 1 Direction: Down
2 2 <- Finish

Total distance between successive points: 10
Distance between start and finish: 2.828427

Explanation / Answer

int main () { int x, y, x_old, y_old,dist; char op='Y'; printf("Enter the coordinates")'; scanf("%d %d",&x_old, &y_old); while(op=='Y') { printf("Enter the next coordinates")'; scanf("%d %d",&x,&y); if(x==x_old) { dist = y-y_old; if (dist
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote