Advertisement
Vasilena

PracticeDayOneExercise1

Jul 6th, 2021 (edited)
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.54 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5.     float a, b, x;
  6.     printf(" a: ");
  7.     scanf("%f", &a);
  8.     printf("b: ");
  9.     scanf("%f", &b);
  10.     if(a == 0 && b == 0)
  11.     {
  12.         printf("x: 0");
  13.     }
  14.     else if(a != 0)
  15.     {
  16.         x = -b / a;
  17.         printf("x: %.2f", x);
  18.     }
  19.     else if(a == 0 && b != 0)
  20.     {
  21.         printf("No solution!");
  22.     }
  23.     return 0;
  24. }
  25.  
  26. //---TEST1---//
  27. /*  a:5
  28.     b:10
  29.     x: -2.00
  30.  
  31. //---TEST2---//
  32.     a:0
  33.     b:19
  34.     No solution!
  35. //---TEST3---//
  36.     a:0
  37.     b:0
  38.     x: 0    */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement