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

I know that the answer is already on here, but what does this part mean?... prin

ID: 3665370 • Letter: I

Question

I know that the answer is already on here, but what does this part mean?... printf("Points distance: %lf ", pointsDistance);

Determine the distance between point (x1, y1) and point (x2, y2), and assign the result to pointsDistance. The calculation is:
Distance = SquareRootOf( (x2 - x1)2 + (y2 - y1)2 )
You may declare additional variables.
Ex: For points (1.0, 2.0) and (1.0, 5.0), pointsDistance is 3.0.

I put in the exact answer that is given but it still says error. I don't understand what "printf("Points distance: %lf ", pointsDistance);" means in the answer. I noticed that a lot of these answers say that same thing and I do not know what to put when it says that.

Can someone please help?

Thank you!

Jake

Explanation / Answer

The first argument to printf() is a format string. In printf(), most things are output directly except for format codes beginning with a '%'. for e.g %d corresponds to a paramter of type integer...similarly here %lf actually corresponds to a parameter of type double (a number with upto 6 digits of precision) . Here pointsDistance is a variable is of type double. So %lf is a special format specifier which causes printf() to load the variable pointed by the corresponding argument (which is pointsDistance of type double in your case).

is just specified to insert a line break; i.e a new-line character shall be inserted at the exact position the line should be broken. In C++, a new-line character can be specified as (i.e., a backslash character followed by a lowercase n).