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
Do you have to include anything in a body of an email in order for it to send
MArishka [77]

Answer:

You dont have to but if you can its optional

Explanation:

6 0
3 years ago
A _____ is a collection of binary digits, including message data and control characters for formatting and transmitting, sent fr
Keith_Richards [23]

Answer:

Packet

Explanation:

8 0
3 years ago
Which are examples of primary sources? Check all that apply.
Marrrta [24]

Answer:

A, D, E

Explanation:

Diaries, photographs, and speeches are all forms of primary sources, whereas biographies and newspaper articles are written by a secondary source.

5 0
3 years ago
Read 2 more answers
Patrick is working on a computer that is having wireless network connection issues. Patrick decides that he needs to take the la
Aneli [31]

Answer:

C

Explanation:

Please give me brainliest!

4 0
2 years ago
Given an integer variable strawsOnCamel, write a statement that uses the auto-increment operator to increase the value of that v
Reptile [31]

Answer:

The program to this question can be given as follows:

Program:

#include <stdio.h> //include header file for using basic function

int main() //defining main method

{

int strawsOnCamel=0; //defining integer variable and assign value

for(int i=1;i<=5;i++) //loop for increment integer variable value

{

//code

strawsOnCamel++; //increment value by 1

printf("%d\n", strawsOnCamel); //print value

}

return 0;

}

Output:

1

2

3

4

5

Explanation:

In the C language code above the header file is entered, and a whole variable strawsOnCamel is specified within the main method, which gives a value of 0.

  • Then a for loop is defined inside a loop an integer variable i declared that starts from 1 and ends with 5.
  • Inside a loop, the strawsOnCamel variable is used that increments its value by 1 and prints its value.

5 0
3 years ago
Other questions:
  • Approximately what percent of U.S. businesses have some form of remote work program? (from Chapter 1)
    14·1 answer
  • Write a short program using a while loop which will display all of the even numbers starting with 12 and ending with 86. (test y
    10·1 answer
  • Which access database object is best to use for the basis of a report when specific criteria must be applied to the report?
    12·2 answers
  • How are envelopes and letterheads different
    6·1 answer
  • You are almost finished updating a Website. As part of the update, you have converted all pages from HTML 4.0 to HTML5. The proj
    7·1 answer
  • A support agent who feels that a user needs substantial assistance with the organization of files on their pc should ____.
    5·1 answer
  • Which of the following identifies the goods or services of a
    15·2 answers
  • Which are guidlines for using themes? Check all that apply
    13·1 answer
  • Create a program that calculates the tip and total for a meal at a restaurant. Type the code into an IDLE IDE editor window and
    5·1 answer
  • What are the answers to these Python programs
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!