Friday, June 18, 2021

program in Java to display the cube of the number upto given an integer (Java) (190)

package com.company;
import java.util.Scanner;
public class Program27 {
public static void main(String[] args) {
Scanner put = new Scanner(System.in);
System.out.println("please enter the number of terms for checking cube:");
int n = put.nextInt();
for(int i=1;i<=n;i++)
{
System.out.print("number is : ");
System.out.print(i);
int cube=i*i*i;
System.out.print(" cube is : ");
System.out.println(cube);
}
}
}

No comments:

Post a Comment