ADVERTISEMENT
ADVERTISEMENT

C program to calculate the surface area, volume of Cone

Here, we are going to learn how to calculate the surface area, volume of Cone using C program?
Submitted by Nidhi, on August 10, 2021

Problem Solution:

Read the height and radius of a Cone from the user, and then calculate the surface area and volume of Cone.

Surface area of Cone:

To calculate the surface area of Cone (Right Circular Cone), the formula is:

surface area of Cone

Volume of Cone:

To calculate the volume of Cone (Right Circular Cone), the formula is:

volume of Cone

Where,

  • r : Radius of the Cone
  • h : Height of the Cone

Program:

The source code to calculate the surface area, volume of the Cone is given below. The given program is compiled and executed using GCC compile on UBUNTU 18.04 OS successfully.

// C program to find the surface Area and
// volume of Cone

#include <stdio.h>
#include <math.h>

int main()
{
    float height = 0;
    float radius = 0;

    float volume = 0;
    float area = 0;

    printf("Enter the height: ");
    scanf("%f", &height);

    printf("Enter the radius: ");
    scanf("%f", &radius);

    volume = (1.0 / 3) * (3.14) * radius * radius * height;
    area = (3.14) * radius * (radius + sqrt(radius * radius + height * height));

    printf("Volume of Cone 	    : %f\n", volume);
    printf("Surface area of Cone: %f\n", area);

    return 0;
}

Output:

RUN 1:
Enter the height: 12.3
Enter the radius: 4
Volume of Cone      : 205.984009
Surface area of Cone: 212.691849

RUN 2:
Enter the height: 1.2
Enter the radius: 3.4
Volume of Cone      : 14.519361
Surface area of Cone: 74.791267

RUN 3:
Enter the height: 10
Enter the radius: 6
Volume of Cone      : 376.799988
Surface area of Cone: 332.750275

Explanation:

Read the value of height and radius from the user. Then we calculated the surface area and volume of Cone using standard formulas.

C Basic Programs »


ADVERTISEMENT




ADVERTISEMENT



Comments and Discussions!

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.