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 cylinder

program to find the volume of cylinder 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 cylinder

A cylinder can be defined as the solid 3D object having two circular faces connected with the rectangular surface. The volume of the cylinder is the amount of space contained by it. The formula to calculate the volume of the cylinder is given below.

Formula

V=pie x r2 x h

where,

r is the radius of the cylinder
h is the height of the cylinder
V is the volume of the cylinder

Algorithm

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

Complexity

O(1)


Solution

C Program

#include 
int main()
{
    int height=38;
    int radius=35;
    double pie=3.14285714286;
    double volume=pie*(radius*radius)*height;
    printf("Volume of the cylinder=%f",volume);
}

Output:

Volume of the cylinder=146300.000000  

PHP Program

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

Output:

Volume of the cube=146300.00000013 

Java Program

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

Output:

Volume of the cylinder=146300.000000133

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;
 Console.WriteLine("Volume of cylinder="+volume);
}
}

Output:

Volume of cylinder=146300.000000133

Python Program

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

Output:

volume of the cube=146300.000000133 

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