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 cube

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

Volume of a cube = side * side * side. 

The cube has all the edges of the same length. The volume of a cube can be calculated by multiplying the length of an edge by itself twice. So if the length of an edge is 4, the volume is 4 x 4 x 4 = 64

Algorithm

  1. Define the value of variable 'a' as the length of an edge of the cube.
  2. Multiply 'a' with 'a' and again multiple the results with 'a' to obtain the volume of the cube.
  3. Define the variable volume_cube and assign the volume of the cube to it.

Complexity

O(1)


Solution

C Program

#include 

int main()
{
    int a=4;
    int volume=a*a*a;
    printf("Volume of the cube=%d",volume);
}

Output:

Volume of the cube=64  

PHP Program

<?php  
   $a=4;
    $volume=$a*$a*$a;
    echo "Volume of the cube=";
    echo $volume;
?>  

Output:

Volume of the cube=64  

Java Program

public class cube{
    public static void main(String args[])
    {
    int a=4;
    int volume=a*a*a;
        System.out.println("Volume ot the cube="+volume);
     }
}

Output:

Volume ot the cube=64

C# Program

using System;					
public class Program
{
	public static void Main()
	{
int a=4;
int volume=a*a*a;
    
   Console.WriteLine("Volume of cube="+volume);
	}
}

Output:

Volume of cube=64

Python Program

a=4
volume=a*a*a
print("volume of the cube="+str(volume))

Output:

volume of the cube=64  

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