C Programs | IT Developer
IT Developer

C Programs



Share with a Friend

C Program: Surface Area of a Cone

Introduction (Cone Surface Area)

A cone is a 3D solid shape with a circular base tapering smoothly to a single point called the apex.
Examples include ice-cream cones, funnels, and party hats.

The surface area of a cone consists of:

  1. Curved Surface Area (CSA):

πrl

where l = sqrt(r2 + h2) is the slant height.

  1. Total Surface Area (TSA):

πr ( r + l )

where

  • r = radius of the base
  • h = height of the cone
  • l = slant height
  • π (pi) ≈ 3.14159

In this program, we calculate the Total Surface Area (TSA).

 

C Program: Surface Area of a Cone

C

#include <stdio.h>

#include <math.h>    // For sqrt function

#define PI 3.14159   // Define constant PI

 

int main() {

    float radius, height, slant_height, surface_area;

 

    // Input radius and height

    printf("Enter the radius of the cone: ");

    scanf("%f", &radius);

 

    printf("Enter the height of the cone: ");

    scanf("%f", &height);

 

    // Calculate slant height using Pythagoras theorem

    slant_height = sqrt((radius * radius) + (height * height));

 

    // Calculate total surface area

    surface_area = PI * radius * (radius + slant_height);

 

    // Display result

    printf("Surface Area of Cone = %.2f\n", surface_area);

 

    return 0;

}

Output

 
OUTPUT 1 :
Enter the radius of the cone: 3
Enter the height of the cone: 4
Surface Area of Cone = 75.40


OUTPUT 2 :
Enter the radius of the cone: 5
Enter the height of the cone: 12
Surface Area of Cone = 254.47


Explanation

  1. Input radius and height of the cone.
  2. Compute slant height using l = sqrt (r^2 + h^2)
  3. Apply formula: π × r × (r + l).
  4. Print the Total Surface Area up to two decimal places.