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
COverview of C : Area and Circumference Calculator I
<01.05>
/* The "circle" program (from keyboard) */
#include <stdio.h> #define PI 3.1416 int main (void) { /* declarations */ double diam, area, circ, r; /* get diameter from user */ printf ("Enter a value for the diameter: "); scanf ("%lf", &diam); /* do the computations */ r = diam / 2; area = PI * r * r; circ = 2 * PI * r; /* display the report on the screen */ printf ("\nA circle with a diameter of %3.1lf cm, ", diam); printf ("has an area of %5.3lf cm2\n", area); printf ("and a circumference of %4.2lf cm.\n", circ); return (0); }
Hergestellt in Deutschland / Made in Germany
Enter a value for the diameter: 10 A circle with a diameter of 10.0 cm, has an area of 78.540 cm2 and a circumference of 31.42 cm.
COPYRIGHT © 2015-2024 IHY PRESS Frankfurt am Main 60329 Deutschland