Skip to content

Instantly share code, notes, and snippets.

@deven9229
Created January 22, 2020 09:18
Show Gist options
  • Save deven9229/2b4ff10a8a1af9aebda15ea81baecd90 to your computer and use it in GitHub Desktop.
Save deven9229/2b4ff10a8a1af9aebda15ea81baecd90 to your computer and use it in GitHub Desktop.
Write a program in Java to display the cube of the number upto given an integer.
package com.deven;
import java.util.Scanner;
public class Cube {
public static void main(String[] args){
Scanner input = new Scanner(System.in);
System.out.println("Enter the number: ");
int num = input.nextInt();
for(int i=1; i<=num; i++){
System.out.println("the cube of " + num + " is " + num*num*num);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment