Q:

Program to find the volume of the cone

belongs to collection: Basic Programs

0

The cone can be defined as the three dimensional object with a circular base. The volume of the cone is measured in cubic units. Be sure that all of the measurements are in the same unit before computing the volume.

Formula

volume of cone= pie x r2 x h/3

Algorithm

  1. Define the height of the cone.
  2. Define the radius of the cone.
  3. Calculate the volume of the cone pie x r2 x h/3
  4. Define volume_cone and assign the volume of the cone to it.

Complexity

O(1)

Input:

Radius = 38Height = 35Pie = 3.14  

Output:

Volume = pie * radius * radius * height/3;
       = 3.14 * 38 * 38 * 35/3
       = 48766.666667

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

C Program

C Program:  
#include <stdio.h>  
int main()  
{  
    int height=38;  
    int radius=35;  
    double pie=3.14285714286;  
    double volume=pie*(radius*radius)*height/3;  
    printf("Volume of the cone=%f",volume);  
}  

 

Output:

Volume of the cone=48766.666667 

 

PHP Program

<?php   
   $height=38;  
    $radius=35;  
    $pie=3.14285714286;  
    $volume=$pie*($radius*$radius)*$height/3;  
    echo "Volume of the cone=";  
    echo $volume;  
?>

    

Output:

The volume of the cone=48766.666666711 

 

Java Program

public class cone{  
    public static void main(String args[])  
    {  
    int height=38;  
    int radius=35;  
    double pie=3.14285714286;  
    double volume=pie*(radius*radius)*height/3;  
        System.out.println("Volume of the cone="+volume);  
     }  
} 

 

Output:

Volume of the cone=48766.666666711004

 

C# Program

using System;                     
public class Program  
{  
public static void Main()  
    {  
int height=38;  
    int radius=35;  
    double pie=3.14285714286;  
    double volume=pie*(radius*radius)*height/3;   
   Console.WriteLine("Volume of cone="+volume);  
    }  
}  

 

Output:

Volume of cone=48766.666666711

 

Python Program

height=38  
radius=35  
pie=3.14285714286  
volume=pie*(radius*radius)*height/3  
print("volume of the cone="+str(volume))

  

Output:

Volume of cone=48766.666666711

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Program to find the volume of the cube... >>
<< Program to find the surface area of the sphere...