Program to find slant height of cone and pyramid | C ++ program for the above approach ; Function to calculate slant height of a cone ; Store the slant height of cone ; Print the result ; Function to find the slant height of a pyramid ; Store the slant height of pyramid ; Print the result ; Driver Code ; Dimensions of Cone ; Function Call for slant height of Cone ; Dimensions of Pyramid ; Function to calculate slant height of a pyramid
#include <bits/stdc++.h> NEW_LINE using namespace std ; void coneSlantHeight ( double cone_h , double cone_r ) { double slant_height_cone = sqrt ( pow ( cone_h , 2 ) + pow ( cone_r , 2 ) ) ; cout << " Slant ▁ height ▁ of ▁ cone ▁ is : ▁ " << slant_height_cone << ' ' ; } void pyramidSlantHeight ( double pyramid_h , double pyramid_s ) { double slant_height_pyramid = sqrt ( pow ( pyramid_s / 2 , 2 ) + pow ( pyramid_h , 2 ) ) ; cout << " Slant ▁ height ▁ of ▁ pyramid ▁ is : ▁ " << slant_height_pyramid << ' ' ; } int main ( ) { double H1 = 4.5 , R = 6 ; coneSlantHeight ( H1 , R ) ; double H2 = 4 , S = 4.8 ; pyramidSlantHeight ( H2 , S ) ; return 0 ; }