Sample format of C program-1vhhh
Sample format of C program-1vhhh
sphere.
OBJECTIVE: The objective of the program is to develop a program that can
effectively calculate area and volume of the sphere.
PROBLEM STATEMENT: Design a program that take radius of a sphere as
input and calculate its area and volume.
ALGORITHM:
1. Start
2. Declare variables:
- radius - to store the radius of the sphere
- area - to store the calculated area of the sphere
- volume - to store the calculated volume of the sphere
- PI (constant ) - to store the approximation of pi (π)
3. Input radius from the user
4. Calculate the area of the sphere:
- area = 4 * pi * radius * radius
5. Calculate the volume of the sphere:
- volume = (4.0 / 3.0) * PI * radius * radius * radius
6. Display area and volume of the sphere as output
7. End
FLOWCHART:
SOURCE CODE:
#include<stdio.h>
#include<conio.h>
void main(){
float vol,area,PI=3.14;
int radius;
clrscr();
Printf(“ Enter radius of the sphere”);
Scanf(“%d”,&radius);
area= 4 * PI * radius * radius;
vol=((4.0/3.0) * PI * radius * radius * radius;
printf("the area and volume of a sphere is %f %f", area , volume);
getch();
}
INPUT / OUTPUT:
Enter radius of the sphere 5
The area and volume of the sphere is 314 , 523.3333
EXECUTION & OUTPUT:
Paste the screen sort of your coding window and execution window.
DISCUSSION:
The above program follows sequential approach to solve the program.
CONCLUSION:
The program successfully meets the objective.