C Program to Find Surface Area of Cone
This C program calculates surface area of cone given radius and height.
Surface area of cone calculated by using following formula:
A = πr ( r + √(r2 + h2) )
C Source Code: Cone Area
To find surface area of cone, we first read radius and height of cone from user and then we apply above formula.
/*
Objective: C program to calculate surface area of cone
Author: Codesansar
*/
#include<stdio.h>
#include<math.h> //for sqrt() function
#define PI 3.141592
int main()
{
float area, radius, height;
// Reading radius
printf("Enter radius of cone: ");
scanf("%f", &radius);
// Reading height
printf("Enter height of cone: ");
scanf("%f", &height);
// Calculating surface area of cone
area = PI * radius * (radius + sqrt(radius*radius + height*height));
// Displaying area
printf("Surface area = %f", area);
return 0;
}
Output
Enter radius of cone: 8 Enter height of cone: 12 Surface area = 563.531372