Need help for sqrt

I want this help for a friend of mine, not for myself.
he made such a coding, but whenever we want a result, the result cannot be found, we could not find where we went wrong. We are new on coding

int a,b,c;
  float x1,x2;
  float delta;

  printf ("a'yi giriniz:");
  scanf ("%d" ,&a);
  printf ("b'yi giriniz:");
  scanf ("%d" ,&b);
  printf ("c'yi giriniz:");
  scanf ("%d" ,&c);

  delta = b^2 -4 *  a  *  c;
  x1 = (-b + (sqrt(delta))) / 2 * a;
  x2 = (-b - (sqrt(delta))) / 2 * a;
   printf ("denklemin 1. kökü %f, 2. kökü %f dir" ,x1,x2);

Is this C? What are you expecting to see? What is happening instead? We need more details.

I dan’t think you want to use ^. You should use **.

Yes, this is C,sorry im really new on coding she said its a solver it finds results according to the numbers you give, but no matter how hard we try, the result is -nan.

Actually, I think you want to square with a*a. ^ is a different thing in C.

int a,b,c;
  float x1,x2;
  float delta;

  printf ("a'yi giriniz:");
  scanf ("%d" ,&a);
  printf ("b'yi giriniz:");
  scanf ("%d" ,&b);
  printf ("c'yi giriniz:");
  scanf ("%d" ,&c);

  delta = b  *  b -4  *  a * c;
  x1 = (-b + (sqrt(delta))) / 2 * a;
  x2 = (-b - (sqrt(delta))) / 2  *  a;
   printf ("denklemin 1. kökü %f, 2. kökü %f dir" ,x1,x2);

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

import library math. Use #include <math.h> in first line

or change in function scanf %d to %f

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.