by CodeChum Admin
We've already tried printing out the values of an array in reversed order, right? Today, we shall compute for the squares of all the numbers.
There's already a predefined array/list containing 100 integer values. Loop through each values, compute their squares, and display them.
Output
Multiple lines containing an integer.
4
9
25
10000
49
9
25
9
1
16
.
.
.
public class App {
/**
* The start point of the program
*
* @param args
*/
public static void main(String[] args) {
int numbers[] = new int[100];
for (int i = 0; i < 100; i++) {
numbers[i] = (int) (Math.random() * 100);
}
for (int i = 0; i < 100; i++) {
System.out.println((numbers[i] * numbers[i]));
}
}
}
Comments
Leave a comment