锥的台体的体积和表面积程序
什么是圆锥台?
圆锥台是通过切除圆锥体的尖端,留下称为圆锥台的上部和下部底面形成的,如图所示。圆锥台的上部底面的半径为“r”,下部底面的半径为“R”,高度为“h”,倾斜的高度为“L”
下面是圆锥台的示意图

问题
给定倾斜的高度、高度、上部底面半径“r”和下部底面半径“R”,任务是计算圆锥台的体积和表面积。
要计算圆锥台的体积和表面积,有一个公式
Volume (V) = 1/3 * pi * h(r2 + R2 + r*R) Curved Surface Area (CSA) = pi * l(R + r) Total Surface Area (TSA) = pi * l(R + r) + pi(R2 + r2)
示例
Input-: r=4 R=9 h=12 L=13 Output-: Volume Of Cone : 1671.33 Curved Surface Area Of Cone : 530.929 Total Surface Area Of Cone : 835.663
算法
Start Step 1 -> define macro as #define pi 3.14 Step 2 -> Declare function to calculate Volume of cone float volume(float r, float R, float h) return (float(1) / float(3)) * pi * h * (r * r + R * R + r * R) Step 3 -> Declare function to calculate Curved Surface area of cone float CSA(float r, float R, float l) return pi * l * (R + r) Step 4 -> Declare function to calculate Total Surface area of cone float TSA(float r, float R, float l, float h) return pi * l * (R + r) + pi * (r * r + R * R) step 5 -> In main() declare variables as R1=4, R2=9, slantHeight=13 and height=12 call volume(R1, R2, height) Call CSA(R1, R2, slantHeight) TSA(R1, R2,slantHeight, height) Stop
示例
#include <iostream>
#define pi 3.14159
using namespace std;
// Function to calculate Volume of cone
float volume(float r, float R, float h){
return (float(1) / float(3)) * pi * h * (r * r + R * R + r * R);
}
// Function to calculate Curved Surface area of cone
float CSA(float r, float R, float l){
return pi * l * (R + r);
}
// Function to calculate Total Surface area of cone
float TSA(float r, float R, float l, float h){
return pi * l * (R + r) + pi * (r * r + R * R);
}
int main(){
float R1 = 4;
float R2 = 9;
float slantHeight = 13;
float height = 12;
cout << "Volume Of Cone : "<< volume(R1, R2, height)<< endl;
cout << "Curved Surface Area Of Cone : "<<CSA(R1, R2, slantHeight)<< endl;
cout << "Total Surface Area Of Cone : "<<TSA(R1, R2,slantHeight, height);
return 0;
}输出
Volume Of Cone : 1671.33 Curved Surface Area Of Cone : 530.929 Total Surface Area Of Cone : 835.663
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP