Advertisement
cyanide_red

3. Multiplication of Elements in Array

Oct 16th, 2018
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.38 KB | None | 0 0
  1. class Product {
  2. public static void main(String[] args)
  3. {
  4. int [] numbers = new int [3];
  5. int multip = 1;
  6. int b = 0;
  7. for (int c = 0; c < numbers.length; c++) {
  8. numbers[c] = b + 2;
  9. b++;
  10. if (c % 2 == 0 & c != 0) {
  11. multip *= numbers[c];
  12. }
  13. }
  14. System.out.println("Произведение элементов массива с чётными индексами = " + multip);
  15. }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement