To calculate the volume of Sphere you need to ask the user to enter the radius of the sphere. PI value is needed to calculate the volume.
Variables:1. radius : (Datatype int): to represent the radius of the Sphere.
2. PI : (Datatype float): static variable to represent constant PI value up to 3 decimal places i.e 3.142
3. volume_of_sphere : (Datatype float): to store volume of Sphere calculated.
Formula: Volume of a Sphere: (4/3) x π x r3
/*
* 1000+ C programs + tutorials
*
*
* 14_calculate_volume_of_sphere.c
*
*
* Created on: Oct 20, 2014
* Author: Code2care.org
*/
#include <stdio.h>
//#include <conio.h>
void main() {
int radius;
float volume_of_sphere;
float PI = 3.142;
// clrscr();
printf(" Program to calculate Volume of a Sphere: ");
printf("\n\n Enter the Radius of Sphere : ");
scanf("%d", &radius);
volume_of_sphere = (4/3)*(PI*radius*radius*radius);
printf("\n\n Volume of Sphere with Radius as %d = %f",radius,volume_of_sphere);
// getch();
}
Output :
Program to calculate Volume of a Sphere :
Enter the Radius of Sphere: 2
Volume of Sphere with Radius as 2 = 25.136000
Programs are divided into categories depending upon type and complexity.
BSc. IT, BSc. Computer Science, BSc. IT, MSc. IT, MSc. Computer Science, MCA, BTech IT & BTech Engineers may find these programs very useful.
More Posts related to C-program,
- Calculate Volume of Cylinder
- Calculate Volume of Sphere
- Calculate Volume of Cube
- Calculate Volume of Ellipsoid
- Find Sum of two numbers
- Division between two numbers
- Calculate Area of Trapezoid
- Calculate Area of a Rectangle
- Calculate Volume of Pyramid
- Calculate Area of ellipse
- Find Difference of two numbers
- Calculate Volume of Cone
- Calculate Area of Square
- Calculate Area and Circumference of Circle
- Calculate Area of Parallelogram
More Posts:
- How to make Android EditText not editable - Android
- Indent XML Formatting In Notepad++ - NotepadPlusPlus
- Send Extra Data with Ajax Get or Post Request - JavaScript
- How to un-hide tab bar in notepad++ - NotepadPlusPlus
- Disable Back Button in Android Programmatically - Android
- 97 Useful Notepad++ Keyboard Shortcuts - NotepadPlusPlus
- How to verify if java is installed on the computer and get version detail - Java
- Eclipse like Auto Import Shortcut in Intelij IDE Android Studio - Android-Studio
- [Solution] Installing Whatsapp There's insufficient space on the device - WhatsApp
- Unhandled exception type InterruptedException : Java Threads - Java
- Delete blank lines in a file using Notepad++ - NotepadPlusPlus
- fill_parent vs match_parent vs wrap_content - Android
- XmlRpcException ConnectException connection refused error - Java
- How to Setup maven on Mac OS X - Mac-OS-X
- Android ListView turns Black or Flickers while Scrolling - Android