Advertisement
Guest User

Untitled

a guest
Oct 24th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3. float raiz (float a, float b, float c, float* x1, float* x2)
  4. {
  5. float delta;
  6. delta=b*b-4*a*c;
  7. if(delta>0)
  8. {
  9. *x1=(-b+sqrt(delta))/(2*a);
  10. *x2=(-b-sqrt(delta))/(2*a);
  11. printf("reais e distintas\n");
  12. }
  13. else if (delta==0)
  14. {
  15. *x1=-b/(2*a);
  16. *x2=*x1;
  17. printf("reais e iguais\n");
  18. }
  19. else
  20. {
  21. printf("imaginarias\n");
  22. }
  23. printf("%f\n", delta);
  24. return delta;
  25. }
  26. int main (void)
  27. {
  28. float delta, a, b, c, x1, x2;
  29. scanf("%f", &a);
  30. while (a!=0)
  31. {
  32. scanf("%f %f", &b, &c);
  33. delta = raiz(a, b, c, &x1, &x2);
  34. printf("%f\n", delta);
  35. if (delta>=0)
  36. {
  37. printf("%f %f\n", x1, x2);
  38. }
  39. scanf("%f", &a);
  40.  
  41. }
  42. return 0;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement