Question
help me
Problem: Write a simple C program that calculates the corresponding y-coordinate for any x-coordinate onaline defined by two
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer:

#include<stdio.h>
#include<stdlib.h>

//main
int main()
{
    //variables declaration
    float x1,y1,x2,y2,m,c,x3,y3;

    //taking inputs of x1,y1,x2,y2
    printf("enter 1st x coordinate:");
    scanf("%f",&x1);

    printf("enter 1st y coordinate:");
    scanf("%f",&y1);

    printf("enter 2nd x coordinate:");
    scanf("%f",&x2);

    printf("enter 2nd y coordinate:");
    scanf("%f",&y2);
    //calculating slope m
    m=(y2-y1)/(x2-x1);
    //calculating y intercept c
    c=y1/(m*x1);
    //printing final equation
    printf("\nFinal line equation: y = %f*x + %f",m,c);
    //input x3
    printf("\n\nenter 3rd x coordinate:");
    scanf("%f",&x3);
    //calculation of y3 from equation
    y3 = m*x3 + c;
    //printing y3
    printf("\n3rd y coordinate = %f.\n\n",y3);

    return 0;
}

OUTPUT:

] X C:\Users\NITISH\Music\BooleanDecision\main.exe enter 1st x coordinate: 4 enter 1st y coordinate: 8 enter 2nd x coordinate//please upvote//

Add a comment
Know the answer?
Add Answer to:
help me Problem: Write a simple C program that calculates the corresponding y-coordinate for any x-coordinate...
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
  • Write a program that asks the user the slope and y-intersect of one line y =...

    Write a program that asks the user the slope and y-intersect of one line y = a_1x + b_1, the slope and y-intersect of a second line y = a_2x + b_2. The program returns the point of intersection of the two lines, if it exists. Otherwise, the program must print a message to indicate that the two lines do not have a point of intersection. Recall that, if it exists, the point of intersection (x_o, y_o) of two lines...

  • Basic C program Problem: In this assignment, you have to read a text file (in.txt) that...

    Basic C program Problem: In this assignment, you have to read a text file (in.txt) that contains a set of point coordinates (x,y). The first line of the file contains the number of points (N) and then each line of the file contains x and y values that are separated by space. The value of x and y are an integer. They can be both negative and positive numbers. You have to sort those points in x-axis major order and...

  • my subject :Introduction to Computer Graphics Problem #1 You need to write a program which implements...

    my subject :Introduction to Computer Graphics Problem #1 You need to write a program which implements both DDA and Bresenham’s Line Generation Algorithms. The program should prompt the user to enter tow points coordinate and then compute and display the estimated coordinate of the line segment on the screen. Example Please enter your line segment starting point? 10 10 Please enter the coordinate of the line segment end point? 50 30 What algorithm to use DDA Bresenham’s Your program should...

  • a. write a program that calculates the sum of two numbers x and y and then...

    a. write a program that calculates the sum of two numbers x and y and then the program should call the function by address and prints the sum b. write a program that stores 10 integers provided at run time in an array. the program should prompt the user for a random integer exit in the array, the value must be replaced by a-1

  • You must write a C program that prompts the user for two numbers (no command line...

    You must write a C program that prompts the user for two numbers (no command line input) and multiplies them together using “a la russe” multiplication. The program must display your banner logo as part of a prompt to the user. The valid range of values is 0 to 6000. You may assume that the user will always enter numerical decimal format values. Your program should check this numerical range (including checking for negative numbers) and reprompt the user for...

  • C++ Code Needed for Lab! Let l be a line in the x-y plane. If l...

    C++ Code Needed for Lab! Let l be a line in the x-y plane. If l is a vertical line, its equation is x = a for some real number a. Suppose l is not a vertical line and its slope is m. Then the equation of l is y = mx + b, where b is the y-intercept. If l passes through the point (x₀, y₀), the equation of l can be written as y - y₀ = m(x...

  • In C only Please! This lab is to write a program that will sort an array...

    In C only Please! This lab is to write a program that will sort an array of structs. Use the functions.h header file with your program. Create a source file named functions.c with the following: A sorting function named sortArray. It takes an array of MyStruct's and the length of that array. It returns nothing. You can use any of the sorting algorithms, you would like though it is recommended that you use bubble sort, insertion sort, or selection sort...

  • Programming Assignment Objective Write a Java program that utilizes multiple classes. Write a Java program that...

    Programming Assignment Objective Write a Java program that utilizes multiple classes. Write a Java program that utilizes inheritance in a practical manner. Problem: Quiz Bowl Your high school quiz bowl team has been losing its edge and needs to find a method to improve. Knowing that you are a savvy programmer, your coach asks you to write a program that the team members can use to hone their skills. Quiz Bowl questions come in three varieties: True/False Multiple Choice (variable...

  • Language: c++ Write a program that opens a file to read 20 floating point numbers and...

    Language: c++ Write a program that opens a file to read 20 floating point numbers and store the information in a 4 x 5 array. The program should do the following: a. Compute the average of each set of 5 values b. Determine the largest value of the 20 values c. Report the results; print the original matrix and average of each row, and the largest of the values in this function. d. At the end of the program prompt...

  • Writing Unix Utilities in C (not C++ or C#) my-cat The program my-cat is a simple...

    Writing Unix Utilities in C (not C++ or C#) my-cat The program my-cat is a simple program. Generally, it reads a file as specified by the user and prints its contents. A typical usage is as follows, in which the user wants to see the contents of my-cat.c, and thus types: prompt> ./my-cat my-cat.c #include <stdio.h> ... As shown, my-cat reads the file my-cat.c and prints out its contents. The "./" before the my-cat above is a UNIX thing; it...

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