C Program To Calculate Surface Area of Cone

Given the values for radius and height of a Cone, write a C program to calculate Surface Area of the Cone.

Formula To Calculate Surface Area of Cone

Surface_Area = PI * radius * (radius + sqrt(height * height + radius * radius ));
where PI is approximately equal to 3.14

Note: sqrt() is a builtin method present in math.h header file.

surface area of cone

Related Read:
Basic Arithmetic Operations In C

Expected Output for the Input

User Input:
Enter radius and height of the cone
2
5

Output:
Surface Area of Cone is 46.378838

Video Tutorial: C Program To Calculate Surface Area of Cone



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

Source Code: C Program To Calculate Surface Area of Cone

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

Output 1:
Enter radius and height of the cone
8
18
Surface Area of Cone is 695.766663

Output 2:
Enter radius and height of the cone
5
14
Surface Area of Cone is 311.897278

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