Write the C++ code for computing the result for b2 -4ac. (logic explained step by step)

Here is the C++ code  for computing the result for b2 -4ac. .It takes input for the variables a,b and c and calculates the result. You all should have in mind how it works exactly. Here is the algorithm.


  Steps
User side
1: User asked to enter the values for the variable 'a', 'b' and 'c'
2: Screen shows the calculated result.
Developer side
1: Declare variables that are going to be used in program .
2: Input the values for the variable 'a', 'b' and 'c' from user.
3: Calculate the formula using following statement 
   x=(b*b)-(4*a*c);
4: Show the value of 'x'.
5: Program ends here.


Code:
#include <iostream>
using namespace std;

int main()
int a,b,c;
    float x;
    cout<<"Enter a= ";
    cin>>a;
    cout<<"Enter b= ";
    cin>>b;
    cout<<"Enter c= ";
    cin>>c;
    x=(b*b)-(4*a*c);
    cout<<"Result="<<x<<endl;
   system("pause");
   return 0;
}

Output:

Comments