
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
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
Find Cube of a Given Number in Java
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
Steps to find a cube of a given number in Java programming:
- 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
Advertisements