IHYPRESS.NET
C
HOME | ASP | C | CSS | HTML | JAVASCRIPT | PERL | PHP | PYTHON | RUBY | SVG
CAdvanced Functions ❯ Two Results from a scanf
<06.07>
/* Problem: This is simple addition reader/parser for 2 doubles. */ #include <stdio.h> /* function to read expression */ void readex (double *op1, double *op2) { char plus; /* no & required in scanf because &*op1 is the same thing as op1 */ scanf ("%lf %c %lf", op1, &plus, op2); } int main(void) { double a, b, c; printf ("Enter an addition expression (eg: 4.5+3.5): "); /* the addresses of the two operands are sent to the function */ readex (&a, &b); c = a + b; printf("%lf + %lf is %lf.\n",a,b,c); return(0); } /* can you expand this program to cover substractions? */
Hergestellt in Deutschland / Made in Germany
Enter an addition expression (eg: 4.5+3.5): 13.4+5.6 13.400000 + 5.600000 is 19.000000.
COPYRIGHT © 2015-2024 IHYPRESS.NET. A DIVISION OF IHY PRESS. ALL RIGHTS RESERVED.