

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Java program to find a cube of a given number
Cube of a value is simply three times multiplication of the value with self.
For example, cube of 2 is (2*2*2) = 8.
Algorithm
- Take integer variable A.
- Multiply A three times.
- Display result as Cube.
Example
import java.util.Scanner; public class FindingCube { public static void main(String args[]){ int n = 5; System.out.println("Enter a number ::"); Scanner sc = new Scanner(System.in); int num = sc.nextInt(); System.out.println("Cube of the given number is "+(num*num*num)); } }
Output
Enter a number :: 5 Cube of the given number is 125
- Related Questions & Answers
- Java program to find the cube root of a given number
- Java program to find the square root of a given number
- Java program to find the factorial of a given number using recursion
- How to find the cube root of a number in JavaScript?
- Java Program to Find Factorial of a number
- Golang Program to find the parity of a given number.
- C# Program to find the cube of elements in a list
- Java program to print Fibonacci series of a given number.
- Java program to find if the given number is a leap year?
- C++ Program to Find the Number of Permutations of a Given String
- How to execute a cube of numbers of a given array in JavaScript?
- Java Program to find largest prime factor of a number
- Java Program to Find Factorial of a Number Using Recursion
- Write a Golang program to find the factorial of a given number (Using Recursion)
- Write a Golang program to find the sum of digits for a given number
Advertisements