C Program To Calculate Surface Area of Sphere

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

surface area of sphere

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 Link: https://www.youtube.com/watch?v=2llOHesCV70 [Watch the Video In Full Screen.]

Source Code: C Program To Calculate Surface Area of Sphere

  1. #include<stdio.h>  
  2.   
  3. int main()  
  4. {  
  5.     const float PI = 3.14;  
  6.           float r, area;  
  7.   
  8.     printf("Enter Radius of the Sphere\n");  
  9.     scanf("%f", &r);  
  10.   
  11.     area = ( 4 * PI * r * r );  
  12.   
  13.     printf("Surface Area of Sphere is %f\n", area);  
  14.   
  15.     return 0;  
  16. }  

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

C Program To Calculate Volume of Sphere

Given the value for radius of a Sphere, write a C program to calculate volume of the Sphere.

Formula To Calculate Volume of Sphere

volume = ( 4 * PI * radius3 ) / 3.0;

OR

volume = ( 1.333 * PI * radius3 );

volume of sphere

where PI is approximately equal to 3.14;

Related Read:
Basic Arithmetic Operations In C

Expected Output for the Input

User Input:
Enter Radius of the Sphere
5

Output:
Volume of Sphere is 523.333374

Logic To Calculate Volume of Sphere

We ask the user to enter value for radius of the Sphere. If user enters 5 inche. Then we use the formula to calculate the Volume of Sphere:

volume = ( 4 * PI * radius3 ) / 3.0;

User input:
radius = 5 inches;

PI value is approximately equal to 3.14;

volume = ( 4 * PI * radius3 ) / 3.0
volume = ( 4 * 3.24 * (5 inches)3) / 3.0
volume = ( ‭12.56‬ * 125 inches3 ) / 3.0
volume = ( ‭12.56‬ * 125 inches3 ) / 3.0
volume = ‭1,570‬ inches3 / 3.0
volume = ‭523.33 inches3

Video Tutorial: C Program To Calculate Volume of Sphere



YouTube Link: https://www.youtube.com/watch?v=rpQzrFSWj6c [Watch the Video In Full Screen.]

Source Code: C Program To Calculate Volume of Sphere

  1. #include<stdio.h>  
  2.   
  3. int main()  
  4. {  
  5.     const float PI = 3.14;  
  6.           float r, volume;  
  7.   
  8.     printf("Enter Radius of the Sphere\n");  
  9.     scanf("%f", &r);  
  10.   
  11.     volume = ( 4 * PI * r * r * r ) / 3.0;  
  12.   
  13.     printf("Volume of Sphere is %f\n", volume);  
  14.   
  15.     return 0;  
  16. }  

Output 1:
Enter Radius of the Sphere
3
Volume of Sphere is 113.040001

Output 2:
Enter Radius of the Sphere
14
Volume of Sphere is 11488.213867

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