C/Math/Square Root

Материал из C\C++ эксперт
Версия от 10:22, 25 мая 2010; Admin (обсуждение | вклад) (1 версия: Импорт контента...)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

Calculate square root: how to use sqrt

#include <stdio.h>
#include <math.h>
int main ()
{
  double param, result;
  param = 1024.0;
  result = sqrt (param);
  printf ("sqrt(%lf) = %lf\n", param, result );
  return 0;
}


Get the square root

#include <stdio.h>
#include <math.h> /* needed by sqrt() */
int main(void)
{
  double answer;
  answer = sqrt(20.0);
  printf("%f", answer);
  return 0;
}