TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

program to find the volume of cone

program to find the volume of cone on fibonacci, factorial, prime, armstrong, swap, reverse, search, sort, stack, queue, array, linkedlist, tree, graph etc.

<< Back to PROGRAM

Program to find the volume of the cone

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)


Solution

C Program

C Program:
#include 
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

Next Topic#




Related Links:


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf