IHYPRESS PROGRAMMING
Tutorials and C programs with code and output for beginners
c programming
HOME | ASP | C | CSS | GNUPLOT | HTML | JAVASCRIPT | PERL | PHP | PYTHON | RUBY | SVG
CAdvanced Functions : Quadratic Equation
<06.01>
/* Problem: This program shows a function that generates two results. One result is returned (-), the other accessed from the main via an address (+). */ #include <stdio.h> #include <math.h> double quadratic (int a, int b, int c, double* xplus) { double xminus; xminus = (-b - sqrt (b * b - 4 * a * c))/ (2 * a); *xplus = (-b + sqrt (b * b - 4 * a * c))/ (2 * a); return (xminus); } int main (void) { int a = 10, b = 40, c = 30; double xplus, xminus; /* calling the function. the address of xplus is sent as an argument */ xminus = quadratic (a, b, c, &xplus); printf ("Using +: %lf\n", xplus); printf ("Using -: %lf\n", xminus); return (0); }
Hergestellt in Deutschland / Made in Germany
Using +: -1.000000 Using -: -3.000000
COPYRIGHT © 2015-2024 IHY PRESS Frankfurt am Main 60329 Deutschland