KnowledgeBoat Logo

Computer Applications

Generate the following series upto 10 terms:

1, 8, 27, 64, 125 ……..

Java

Java Iterative Stmts

38 Likes

Answer

public class KboatSeries
{
    public static void main(String args[]) {
        int a = 1;
        for (int i = 1; i <= 10; i++) {
            int t = a * a * a;
            System.out.print(t + " ");
            a++;
        }
    }
}

Output

BlueJ output of Generate the following series upto 10 terms: 1, 8, 27, 64, 125 ……..

Answered By

17 Likes


Related Questions