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
kayah has created a website that explains what her business does. what type of computer program is needed to access/view kayah's
soldier1979 [14.2K]

Answer:

web browser

Explanation:

A web browser is a program that allows users to view and explore

information on the World Wide Web.

8 0
3 years ago
Read 2 more answers
Bruh why is everyone skipping my question!!!!!!!
DiKsa [7]

Answer:

What is your question?

Explanation:

7 0
3 years ago
How does and employer judge a candidate
nlexa [21]

Answer:

Explanation:

An employer can judge a candidate from these factors.

1) Confidence Level

2) Way of talking

3) Written or screening test

4) Experience Level

5) Resume

6 0
3 years ago
What is the music form for the song "Sunflower?
Leni [432]

Answer:

spiderman i believe. by post malone

Explanation:

4 0
3 years ago
Read 2 more answers
Machine language—0s and 1s—would be very difficult for a programmer to write in; thus a low-level (second-generation) language,
adelina 88 [10]

Answer:

Assembly Language.

Explanation:

Machine Language:- It is the lowest level programming language.It represent that the data in the form of 1's and 0's it is like this because the machines understand only binary or 1's and 0's.

Assembly Language:-It is the second generation of programming language.It can be used by a programmers to write program using abbreviations and basic words instead of binary numbers.

5 0
3 years ago
Other questions:
  • 5) How have the wireless web and peer-to-peer networking helped small businesses compete with large corporations?
    15·2 answers
  • Which type of software is created and updated by a worldwide community of programmers and is available for​ free?
    14·1 answer
  • Which is NOT a way the network operating sys-
    6·1 answer
  • What is a series of instructions or commands that a computer follows used to create software
    9·1 answer
  • Help me please and thanks
    8·1 answer
  • 9.1.3: Printing vector elements with a for loop. Write a for loop to print all NUM_VALS elements of vector courseGrades, followi
    5·1 answer
  • You are trying to connecting your laptop to your new 52" LED TV using an HDMI connector. When you connect everything, you immedi
    15·1 answer
  • In PowerPoint, Jake wants to change the slide background to a photo on his computer. He is walking through a tutorial given to h
    7·1 answer
  • 22. Write the following in full un computer
    5·1 answer
  • Explain employment opportunities in the networking field 
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!