Question

cs 101-03/05 computers & programming, Due: 04/18/2019 (sharp) Programming Horneworkr, Modules Make sure to include your name,
0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include<stdio.h>
#include<math.h>
void distance(){
int x1, y1, x2, y2, temp;
double dist;
printf("Enter x1, y1, x2, y2\n");
scanf("%d %d %d %d ", &x1, &y1, &x2, &y2);
temp = (x2-x1)*(x2-x1)+(y2-y1)*(y2-y1);
dist = sqrt(temp); //Computing square root as per formula
printf("%lf", dist);
}
void slope(){
int x1, y1, x2, y2;
double sl;
printf("Enter x1, y1, x2, y2\n");
scanf("%d %d %d %d ", &x1, &y1, &x2, &y2);
sl = (x2-x1)/(y2-y1); //Computing slope as per formula
printf("%lf", sl);
}
void equation(){
int x1, y1;
double slope, temp;
printf("Enter x1, y1\n");
scanf("%d %d", &x1, &y1);
printf("Enter slope\n");
scanf("%lf", &slope);
temp = slope*x1 - y1; // a variable to hold sum of m*x1 - y1
printf("equation is :%lfx-y=%lf", slope, temp);
}
int main(){
int choice, k1;
printf("What do you want to compute\n1. Slope\n2. Distance between two points\n3. Equation of a line passing through a point\n");
scanf("%d ", &choice);
if(choice > 0 && choice < 4){ //Menu for all three operations
if(choice==1){slope();}
if(choice==2){distance();}
if(choice==3){equation();}
}
else{printf("Enter valid choice\n");}
return 0;
}

Add a comment
Know the answer?
Add Answer to:
cs 101-03/05 computers & programming, Due: 04/18/2019 (sharp) Programming Horneworkr, Modules Make sure to include your...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • how to make my code of python work probely my q is how to write a...

    how to make my code of python work probely my q is how to write a code to find the average actual water level, average error by using python and my program should be flexible where user can select the column no. If you can see in the main program, it asked which column to know the maximum or average, the column number is passed to the function. The function should look which column to do. #THIS PROGRAMMING IS ABLE...

  • 18.1 Lab Lesson 11 (Part 1 of 1) Part of lab lesson 11 There in one...

    18.1 Lab Lesson 11 (Part 1 of 1) Part of lab lesson 11 There in one part to lab lesson 11. The entire lab will be worth 100 points. Lab lesson 11 part 1 is worth 100 points For part 1 you will have 80 points if you enter the program and successfully run the program tests. An additional 20 points will be based on the style and formatting of your C++ code. Style points The 20 points for coding...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT