Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package class170629;
- public class arrays03 {
- public static void main(String[] args) {
- /*
- * Exercise 3, slide 28
- * input : none
- * output: first 10 multiplications of
- * 3 (from an array)
- */
- // define an integer array, size=10
- int[] numbers = new int[10];
- // scan the array
- for (int i = 0; i < numbers.length; i += 1) {
- // in position i store the number 3*i
- numbers[i] = 3 * i;
- // print numbers from the array
- System.out.printf("%d ", numbers[i]);
- }
- System.out.println();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement