Problem Statement: You are required to write a program that prompts the user to enter the radius of circle as an input and display the circle’s diameter, circumference and area. Use the constant value 3.14159 for л. Perform each of these calculations inside the printf statements and use the conversion specifier %f.
(a) Write a pseudo-code to solve this problem.
(b) Write a full program using C programming language to solve this problem.
1
Expert's answer
2012-07-12T08:25:35-0400
Pseudo-code:
take radius print radius²·pi print 2pi·radius
# include<iostream.h> # include<conio.h>
double pi = 3.1419, r;
void main(){ cout<<"Enter the radius of a circle: "; cin>>r; printf("The diameter of a circle is %f \n", 2*r); printf("The area of a circle is %f \n", pi*r*r); printf("The circumference of a circle is %f \n", 2*pi*r); getch(); }
Comments
Leave a comment