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
zubka84 [21]
3 years ago
7

Write a C program to calculate and display the coordinates of midpoint - M of a linesegment between two given points - say A and

B, the slope of the line - s and the distance b/wthe points A and B given by d. Your program should prompt the user to enter floating pointvalues for x and y coordinates for the two points - A (x1, y1) and B (x2, y2). Then it calculatesthe floating point coordinates of the midpoint - M (xm, ym) using the formula -Xm
Computers and Technology
1 answer:
pychu [463]3 years ago
6 0

Answer:

//Program in C.

// header file

#include <stdio.h>

#include <math.h>

// main function

int main(void) {

   // variables

float x1,y1,x2,y2;

float s,xm,ym,d;

// ask to enter x coordinate of A

printf("Enter coordinate (x) of point A:");

// read x1

scanf("%f",&x1);

// ask to enter y coordinate of A

printf("Enter coordinate (y)  of point A:");

// read y1

scanf("%f",&y1);

// ask to enter x coordinate of B

printf("Enter coordinate (x) of point B:");

//read x2

scanf("%f",&x2);

// ask to enter y coordinate of B

printf("Enter coordinate (y) of point B:");

// read y2

scanf("%f",&y2);

// calculate Midpoint of A and B

xm=(x1+x2)/2;

ym=(y1+y2)/2;

// calculate slope of the line

s=(y2-y1)/(x2-x1);

// calculate Distance between two points

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

// print result

printf("Midpoint of both the point is: %f %f",xm,ym);

printf("\nSlope of both the line is: %f",s);

printf("\nDistance between both the point is: %f",d);

return 0;

}

Explanation:

Read the x & y coordinates of both the points.Then calculate the Midpoint of both the and assign it to variables "xm"&"ym".Then calculate the slope of the line and assign it to variable "s".Then find the distance between the two points and assign it to variable "d".Print all these results.

Output:

Enter coordinate (x) of point A:2

Enter coordinate (y) of point A:3

Enter coordinate (x) of point B:9

Enter coordinate (y) of point B:8

Midpoint of both the point is: 5.500000 5.500000

Slope of both the line is: 0.714286

Distance between both the point is: 8.602325

You might be interested in
What is a transducer? A. an energy-converting device B. a sensing device C. a robot movement D. a signal display unit
frosja888 [35]

Answer:

Transducer is a device that can convert an electronic controller output signal into a standard pneumatic output.

So our answer would be A

8 0
3 years ago
In a spreadsheet, cells B2 through B10 store the cost price of items and cells C2 through C10 store the selling price. If the se
Ad libitum [116K]
The correct formula to use is <span>=IF(C2>B2;"Profit";"Loss"). The condition set is that if the selling price(C Column) is greater than the cost price(B Column), you earn a profit. When encoded in the formula, the translation in this statement would be C2>B2. When you use the formula </span>=IF(C2>B2;"Profit";"Loss"), the first word will be shown when the condition set is applicable. <span>In this case, if the condition is true, it displays the word "Profit" but otherwise, it displays "Loss".          </span>
4 0
3 years ago
Read 2 more answers
Betty removed a web page from her website. Some users were browsing on her website. One of them clicked on a particular link and
Fittoniya [83]
To prevent users from seeing error pages and ensure that they have a pleasant experience in your application you can add the customErrors element to your Web.config file.  <span>Handling error codes and exceptions by the web.xml, you can configure </span>error-page elements<span> that act upon some error-code or exception-type.</span>
4 0
4 years ago
Write code using the range function to add up the series 20, 30, 40, ... 90 and print the resulting sum each step along the way.
andrew11 [14]

Answer:I DK but if you expaln it I can help. Sorry.

Explanation:

3 0
3 years ago
Read the section, "Junior Year." Why would someone chose to complete an apprenticeship after high school? How many occupations c
Tamiku [17]

An apprenticeship prepares you for a career through a structured program of on-the-job learning with classroom instruction, while you work and earn a salary. The programs can last from one to six years and you can choose careers in areas such as telecommunications, health care, computing, business support and the arts. The most common apprenticeships are in construction and manufacturing. If you like to work with your hands and your mind, you might want to consider an apprenticeship after high school. More than 850 occupations can be learned on the job through an apprenticeship.

7 0
3 years ago
Read 2 more answers
Other questions:
  • 1. Which of the following might be a problem taken on by environment engineers?
    8·1 answer
  • Why is it more important now than ever before to know how to evaluate websites and other online sources of information?
    7·1 answer
  • in c++, what happends when i add 1 to the RAND_MAX then take rand() deivded by (RAND_MAX+1)?if my purpose is to take out a rando
    11·1 answer
  • Use both if and else may contain only one statement, you would have to use a ______ if you want to use more than one instruction
    14·1 answer
  • Write a program segment with a do-while loop that displays whether a user-entered integer is even or odd. The code should then a
    5·1 answer
  • Explain how a monitor can display the letters that you type on a keyboard. (Hint: Three Basic Computer Functions) *
    11·1 answer
  • Public class Dog
    7·1 answer
  • The distance between two walls is called what?
    8·2 answers
  • How to look at things you previously applied to on handshake
    13·1 answer
  • Exam Instructions
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!