IHYPRESS.NET > C PROGRAMMING
HOME | CLASSIC ASP | C | HTML/CSS | JAVASCRIPT | PERL | PHP | PYTHON | RUBY
C > 05. Functions I [PROGRAM #05]
CODERESULT
<
/* The bigger function: two arguments, one result */
#include <stdio.h> /* a function taking two double numbers and returning the larger number of the two */ /* this function will return a double */ double bigger (double n1, double n2) { double big; if (n1>n2) big = n1; else big = n2; return (big); } int main (void) { double x, y, result; printf ("Enter a real number: "); scanf ("%lf", &x); printf ("Enter a real number: "); scanf ("%lf", &y); /* calling the function (2 arguments) */ result = bigger (x,y); /* printing the report */ printf ("The bigger number is %lf.\n", result); return (0); }
Legend: preprocessor directives | variable declarations main function | helper functions | user-defined structures comments
Enter a real number: 12.4
Enter a real number: 67.3
The bigger number is 67.300000.
>
COPYRIGHT © 2021 IHYPRESS.NET. A DIVISION OF IHY PRESS, KIRKLAND, WA 98083 USA. ALL RIGHTS RESERVED.