i want to enter x1,x2 and y1,y2 and it displays the slope of the line...but there are some errors ,can anyone figure it out ?

#include<stdio.h>
#include<conio.h>
/* 2 point form*/
float findslope(float , float,float , float);
float m,n;
void main()


    {
    float a1,b1,a2,b2,;
    double result

    cout << "\n Enter in order x1,x2,y1,y2: ";
    cin>>x1>x2>>y1>>y2>>\n;
    
    result = findslope(x1,x2,y1,y2);
    
    cout <<  result\n;
    rr = y1 - result*x1;
    cout<< "\nEquation:y - %fx = %f",result,rr);
    getch();
}
float findslope(float a1,float a2,float b1, float b2)

    {
    float result;
    result = b1 - b2;
    result = result/(a1 - a2);
    return(result);
}

There are a lot of errors. You should try to find and fix them first. Read the error messages, look at the lines they point you to.

One hint, you're trying to mix C style and C++ style output - choose one.

i want c++ ...can u write the code please ...i need it urgent

float x1,x2,y1,y2;
   cin>>x1>>y1>>x2>>y2;
   
   float slope;
   
   slope=(y2-y1)/(x2-x1);
   
   float c=y1-slope*x1;
   
   cout<<"\nThe equation of the line is : y="<<slope<<" x + "<<c<<endl;

is that it??

i want c++ ...can u write the code please ...i need it urgent

Did you fix the errors? When you do, repost and ask questions. Do NOT ask us to do your work for you.

And stop using QUOTE tags when you need CODE tags.

still don't want to run ...this is what i wrote exactly

#include<stdio.h>
#include<iostream.h>
#include<conio.h>
/* 2 point form*/

float x1,x2,y1,y2;
cout << "\n Enter values in order x1,x2,y1,y2: ";

   cin>>x1>>x2>>y1>>y2;
   
   float slope;
   
   slope=(y2-y1)/(x2-x1);
   
   float c=y1-slope*x1;
   
   cout<<"\nThe equation of the line is : y="<<slope<<" x + "<<c<<endl;

the errors is liek this
17 C:\Dev-Cpp\main3.cpp expected constructor, destructor, or type conversion before '<<' token
17 C:\Dev-Cpp\main3.cpp expected `,' or `;' before '<<' token
C:\Dev-Cpp\Makefile.win [Build Error] [main3.o] Error 1
and sorry for making quotes tags,where is the CODE tags ?

the errors is liek this
17 C:\Dev-Cpp\main3.cpp expected constructor, destructor, or type conversion before '<<' token
17 C:\Dev-Cpp\main3.cpp expected `,' or `;' before '<<' token
C:\Dev-Cpp\Makefile.win [Build Error] [main3.o] Error 1
and sorry for making quotes tags,where is the CODE tags ?

[code] at the beginning, then [/code] at the end

Where's your int main() declaration? Go back to your book and reread the section on basic program structure. Use the Hello world program as a guide.

#include<stdio.h>
#include<conio.h>

Omit these header files because they are C header files. C++ use #include <iostream>

double result;

Make sure every statement is end with semi-color( ; ).

cout << "\n Enter in order x1,x2,y1,y2: ";
    cin>>x1>x2>>y1>>y2>>\n;

To gain access to use cout and cin functions, you need to include <iostream>. Moreover, these function are located in std namespace. In order to use them, namespace need to be mentioned which can be call like this std::cout, std::cin.

cin>>x1>x2>>y1>>y2>>\n;

It suppose to be >> not >, and "\n" not \n

invisal, you were doing good till:

cin>>x1>x2>>y1>>y2>>\n;
It suppose to be >> not >, and "\n" not \n

You cannot input to the newline, and there is no need to add a newline anyway. That will occur when the program user hits the enter key. If the user wants an extra blank line after the intput, it should be written as:

std::cin >> x1 >> x2 >> y1 >> y2;
    std::cout << endl;    // or '\n' in place of endl if you want.  or "\n"

(I see students trying to end input lines in a similar fashion all the time. )

My bad :( . I forgot that it was a std::cin.

Okay the errors are as following:
1.

#include<stdio.h>
#include<conio.h>

There is no need to put this. However the include you need is

#include <iostream>

2.

void main()


{
float a1,b1,a2,b2,;
double result

cout << "\n Enter in order x1,x2,y1,y2: ";

You need to end this line with ;

3.

cout << "\n Enter in order x1,x2,y1,y2: ";
cin>>x1>x2>>y1>>y2>>\n;

This is incorrect. If you do this you will get a compiler error. There is two ways to do this the correct way.

Frist way:

cout << "\n Enter in order x1,x2,y1,y2: ";
cin>>x1>x2>>y1>>y2;
cout << endl;

Second way:

cout << "\n Enter in order x1,x2,y1,y2: ";
cin>>x1>x2>>y1>>y2;
cout << "\n";

and you have to do the same here:

result = findslope(x1,x2,y1,y2);

cout << result\n;

4.

rr = y1 - result*x1;

You haven't declared this.

5.

cout<< "\nEquation:y - %fx = %f",result,rr);

I think i know what you were trying to do here but the correct way is:

cout<< "\nEquation:y - %fx = %f"<<result<<rr;

6.

float result;
result = b1 - b2;
result = result/(a1 - a2);

You can do this in one line:

result = (b1 -b2)/(a1 - a2)

return(result);

the correct way to do this is:

return result;

I MAY BE REPEATING SOME STUFF THAT OTHER PEOPLE POSTED BUT I THOUGHT IT WOULD BE MORE HELPFUL IF I PUT EVERYTHING TOGETHER

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.