Question: Write a program that reads in the radius of a circle and prints the circle’s diameter, circumference and area. Use the constant value 3.14159 for π. Perform each of these calculations inside the printf statement(s) and use the conversion specifier %f.

1 2 |
/* <br /> * Author: AGHATISE OSAZUWA<br /> * Website: www.cscprogrammingtutorials.com <br /> *<br /> * Program to calculate the diameter, circumference and area of a circle.<br /> */<br /><br />#include <stdio.h><br />int main ( ){<br /> int rad;<br /> puts("Enter radius of circle: ");<br /> scanf("%d", &rad);<br /> printf("Diameter is %dn", 2 * rad);<br /> printf("Circumference is %fn", 2 * 3.14159 * rad);<br /> printf("Area is %fn", 3.14159 * rad * rad);<br /> return 0;<br />}<br /> |

Program Output |

Click here to see other solutions to Deitel C How To Program exercises.