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...

  • 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...

  • 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...

  • 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...

  • //Done in C please! //Any help appreciated! Write two programs to write and read from file...

    //Done in C please! //Any help appreciated! Write two programs to write and read from file the age and first and last names of people. The programs should work as follows: 1. The first program reads strings containing first and last names and saves them in a text file (this should be done with the fprintf function). The program should take the name of the file as a command line argument. The loop ends when the user enters 0, the...

  • C++ (1) Write a program to prompt the user for an input and output file name....

    C++ (1) Write a program to prompt the user for an input and output file name. The program should check for errors in opening the files, and print the name of any file which has an error, and exit if an error occurs. For example, (user input shown in caps in first line, and in second case, trying to write to a folder which you may not have write authority in) Enter input filename: DOESNOTEXIST.T Error opening input file: DOESNOTEXIST.T...

  • Please help and follow instructions, c++ , let me know if there is any questions Description:...

    Please help and follow instructions, c++ , let me know if there is any questions Description: This program is part 1 of a larger program. Eventually, it will be a complete Flashcard game. For this part, the program will Prompt the user for a file that contains the questions – use getline(cin, fname) instead of cin >> fname to read the file name from the user. This will keep you in sync with the user’s input for later in the...

  • Problem: Design and write a C language program that can be used to calculate Voltage, Current...

    Problem: Design and write a C language program that can be used to calculate Voltage, Current and Total Resistance for a Series or Parallel or a Series Parallel circuit. The program should display the main menu that contains the three types of circuit calculations that are available and then the user will be prompted to select a circuit first. After the circuit has been selected the program should then display another menu (i.e., a submenu) requesting the necessary data for...

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
ADVERTISEMENT