1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
marin [14]
3 years ago
5

Write a C program that gets 4 integer values from the user, namely, x1, x2, y1, and y2, and then calculates and returns the dist

ance according to the above formula. Use whatever format for entering your data you like. Your program should prompt the user for these values, accept input from the keyboard, and then print out the result. You will have to execute the program four times to cover the test cases below (feel free to use a loop if you want to work ahead). Include a screenshot (or four) that shows the results for the following values: 1) (2,3), (4,5) 2) (4,3), (-6,-5) 3) (-1,3), (4,-2) 4) (-9,-12), (-7, -8)
Computers and Technology
1 answer:
lidiya [134]3 years ago
4 0

Answer:

#include <stdio.h>

#include <math.h>

int main(){

   float x1,x2,y1,y2,distance;

   printf("x1: ");    scanf("%f", &x1);

   printf("y1: ");    scanf("%f", &y1);

   printf("x2: ");    scanf("%f", &x2);

   printf("y2: ");    scanf("%f", &y2);

   distance = sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));

   printf("Distance: %f", distance);

   return 0;

}

Explanation:

This line declares all required variable (i.e. the coordinates and the distance)

   float x1,x2,y1,y2,distance;

The next four line prompt and get input for the coordinates

<em>    printf("x1: ");    scanf("%f", &x1);</em>

<em>    printf("y1: ");    scanf("%f", &y1);</em>

<em>    printf("x2: ");    scanf("%f", &x2);</em>

<em>    printf("y2: ");    scanf("%f", &y2);</em>

This calculates the distance

   distance = sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));

This prints the calculated distance

   printf("Distance: %f", distance);

<em>See attachment for sample runs</em>

You might be interested in
A single central register of IP addresses and names (a DNS style system) is an efficient means of translating human readable nam
Harrizon [31]

Answer:

True

Explanation:

DNS stands for "Domain Name System" DNS is the system/service that is used to convert the Domain Names into IP addresses.

Whenever we write a URL to go to a web page in our browser for example Brainly(dot)com, the request first goes to a server which converts the named URL(Brainly(dot)com) into actual IP address. This actual IP address is then used to reach to the web files, as response to the URL search. This system is made to ease out the searches made by the users.

Therefore, the given statement is True.

8 0
4 years ago
How many Iron molecules are in the compound Fe4O2?
Greeley [361]

Explanation: Determine the mass of the substance, and its molar mass. Divide the given mass by its molar mass to get moles, then multiply times 6.022×1023molecules1mol

5 0
4 years ago
Read 2 more answers
A good digital citizen is ________.
goblinko [34]
A good digital citizen is judgmental (A), they use good judgment and treat others with respect.
4 0
3 years ago
You must lower your high beams when within how many feet of an approaching vehicle?
drek231 [11]

2000 feet of any vehicle

7 0
3 years ago
Helpppp pleaseee thanksss​
Archy [21]

Answer:

B!

Explanation:

i think... Here is an example

3 0
3 years ago
Other questions:
  • What is a WYSIWIG program
    10·1 answer
  • CUANTO ES DOS MAS DOS POR FAVOR URGENTE :V
    10·2 answers
  • Which of the following are examples of IT careers? Check all of the boxes that apply.
    12·2 answers
  • Why should the government create money it doesn’t have?
    5·2 answers
  • How many bits can a memory chip with the below configuration support? For full credit, show how you got the answer.
    15·1 answer
  • The Android operating system was invented by ______.
    13·1 answer
  • What are the advantages to using a linked implementation as opposed to an array implementation?
    8·1 answer
  • There are some processes that need to be executed. Amount of a load that process causes on a server that runs it, is being repre
    7·1 answer
  • Do all careers or professions need computer science? Why or why not?
    5·2 answers
  • Film’s importance in today’s economy?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!