SHARE
TWEET
Untitled
a guest
Feb 1st, 2017
76
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- double heron (double);
- double zahl = 0;
- int main() {
- printf ("Bitte geben Sie eine nicht-negativa Zahl ein: ");
- scanf ("%lf", &zahl);
- printf ("Die Wurzel von %f ist laut sqrt Funktion: %f\n", zahl, sqrt(zahl));
- printf ("Die Wurzel von %f ist laut heron Funktion: %f", zahl, heron(zahl));
- return 0;
- }
- double heron (double zahl) {
- double x = (zahl+1)/2;
- double check = 0;
- while (fabs(check - x) >= 0.00010 ) {
- check = x;
- x = (x+(zahl/x))/2;
- }
- return x;
- }
RAW Paste Data
