daily pastebin goal
33%
SHARE
TWEET

Untitled

a guest Feb 1st, 2017 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. double heron (double);
  5. double zahl = 0;
  6.  
  7. int main() {
  8.  
  9.     printf ("Bitte geben Sie eine nicht-negativa Zahl ein: ");
  10.     scanf ("%lf", &zahl);
  11.     printf ("Die Wurzel von %f ist laut sqrt  Funktion: %f\n", zahl, sqrt(zahl));
  12.     printf ("Die Wurzel von %f ist laut heron Funktion: %f", zahl, heron(zahl));
  13.  
  14.     return 0;
  15. }
  16.  
  17. double heron (double zahl) {
  18.  
  19.     double x = (zahl+1)/2;
  20.     double check = 0;
  21.  
  22.     while (fabs(check - x) >= 0.00010 ) {
  23.         check = x;
  24.         x = (x+(zahl/x))/2;
  25.         }
  26.     return x;
  27. }
RAW Paste Data
Top