Given the value for radius of a Sphere, write a C program to calculate Surface Area of the Sphere.
Formula To Calculate Surface Area of Sphere
When radius value is known: Area = 4 * π * radius²,
When diameter value is known: Area = π * diameter²,
When volume value is known: Area = ³√(36 * π * Volume²).
where π (PI) is approximately equal to 3.14
Related Read:
Basic Arithmetic Operations In C
Logic To Calculate Surface Area of Sphere
We ask the user to enter the value of radius of the sphere. We apply the formula:
Surface_ Area = 4 * PI * radius2
where π (PI) is approximately equal to 3.14
Expected Output for the Input
User Input:
Enter Radius of the Sphere
5
Output:
Surface Area of Sphere is 314.000000
Video Tutorial: C Program To Calculate Surface Area of Sphere
[youtube https://www.youtube.com/watch?v=2llOHesCV70]
Source Code: C Program To Calculate Surface Area of Sphere
#include<stdio.h> int main() { const float PI = 3.14; float r, area; printf("Enter Radius of the Sphere\n"); scanf("%f", &r); area = ( 4 * PI * r * r ); printf("Surface Area of Sphere is %f\n", area); return 0; }
Output 1:
Enter Radius of the Sphere
2
Surface Area of Sphere is 50.240002
Output 2:
Enter Radius of the Sphere
10
Surface Area of Sphere is 1256.000000
For list of all c programming interviews / viva question and answers visit: C Programming Interview / Viva Q&A List
For full C programming language free video tutorial list visit:C Programming: Beginner To Advance To Expert