C program to find volume and surface area of sphere; Through this tutorial, we will learn how to find or calculate volume and surface area of sphere using standard formula and function in c programs.
Programs to Find Volume and Surface Area of Sphere in C
To find or calculate volume and surface area of sphere using standard formula and function in c programs:
- C Program to Find Volume and Surface Area of Sphere using Standard Formula
- C Program to Find Volume and Surface Area of Sphere using Function
C Program to Find Volume and Surface Area of Sphere using Standard Formula
/* C Program to find Volume and Surface Area of Sphere */ #include <stdio.h> #define PI 3.14 int main() { float radius, sa,Volume; printf("\n Please Enter the radius of a Sphere :-"); scanf("%f", &radius); sa = 4 * PI * radius * radius; Volume = (4.0 / 3) * PI * radius * radius * radius; printf("\n The Surface area of a Sphere = %.2f", sa); printf("\n The Volume of a Sphere = %.2f", Volume); return 0; }
The output of the above c program; as follows:
Please Enter the radius of a Sphere :-10 The Surface area of a Sphere = 1256.00 The Volume of a Sphere = 4186.67
C Program to Find Volume and Surface Area of Sphere using Function
#include <stdio.h> #define PI 3.14 float volSur(float r) { float sa,Volume; sa = 4 * PI * r * r; Volume = (4.0 / 3) * PI * r * r * r; printf("\n The Surface area of a Sphere = %.2f", sa); printf("\n The Volume of a Sphere = %.2f", Volume); } int main() { float r; printf("\n Please Enter the radius of a Sphere :-"); scanf("%f", &r); volSur(r); return 0; }
The output of the above c program; as follows:
Please Enter the radius of a Sphere :-10 The Surface area of a Sphere = 1256.00 The Volume of a Sphere = 4186.67