Click here to Skip to main content
15,880,972 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
the programm should request for the values of the constanta,b and c and print the values of x1 and x2 use the following rules
no solution if both a and b are zero
there is only one root if a=0 (x=-c/b)
there are no real roots if b2-4ac is negative
otherwise there are 2 real roots

What I have tried:

C++
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
float a,b,c,x1,x2,xr,xi,dis;
printf("enter the number\n");
scanf("%f%f%f",&a,&b,&c);
if(a==0&&b==0);
{
else if(a==0)
}
x=-c/b;
printf("only one root is exists");
printf("the value of x=%f",x);
Posted
Updated 11-Mar-18 9:51am
v2
Comments
Patrice T 11-Mar-18 7:55am    
did you pasted all your code ?
Richard MacCutchan 11-Mar-18 9:54am    
Make more use of the spacebar on your keyboard. Your scanf will fail because the string expects three floating point numbers with no intervening spaces. So how do you think the scanner can tell where one number ends and the next one starts?

We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, you may find it is not as difficult as you think!

If you meet a specific problem, then please ask about that and we will do our best to help. But we aren't going to do it all for you!
 
Share this answer
 
Get a more modern compiler.
You program had some bugs, iI fixed those, now you have to complete it
C
#include <stdio.h>
#include <math.h>

int main()
{
  double a, b, c;
  printf("plaease enter the coefficients\n");
  scanf("%lf %lf %lf",&a,&b,&c);
  if( a == 0.0 )
  {
    if ( b == 0.0)
    {
      printf("sorry, no roots\n");
    }
    else
    {
      double x = - c / b;
      printf("only one root is exists: %f\n",  x);
    }
  }
  else
  { // here a != 0.0
    // ...
  }
  return 0;
}
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900