- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Java program for Multiplication of Array elements.
To find the product of elements of an array.
- create an empty variable. (product)
- Initialize it with 1.
- In a loop traverse through each element (or get each element from user) multiply each element to product.
- Print the product.
Example
import java.util.Arrays; import java.util.Scanner; public class ProductOfArrayOfElements { public static void main(String args[]){ System.out.println("Enter the required size of the array :: "); Scanner s = new Scanner(System.in); int size = s.nextInt(); int myArray[] = new int [size]; int product = 1; System.out.println("Enter the elements of the array one by one "); for(int i=0; i<size; i++){ myArray[i] = s.nextInt(); product = product * myArray[i]; } System.out.println("Elements of the array are: "+Arrays.toString(myArray)); System.out.println("Sum of the elements of the array ::"+product); } }
Output
Enter the required size of the array: 5 Enter the elements of the array one by one 11 65 22 18 47 Elements of the array are: [11, 65, 22, 18, 47] Sum of the elements of the array:13307580
- Related Articles
- C++ program for multiplication of array elements
- Java Program to find reminder of array multiplication divided by n
- Python Program for Find reminder of array multiplication divided by n
- Java program to print a multiplication table for any number
- JavaScript program for counting frequencies of array elements
- Javascript Program for Range Queries for Frequencies of array elements
- Java Program to sort a subset of array elements
- Java Program to Print the Elements of an Array
- Java Program to Generate Multiplication Table
- C++ Program to Implement Booth’s Multiplication Algorithm for Multiplication of 2 signed Numbers
- Java Program for array rotation
- C Program for Matrix Chain Multiplication
- Java program to find the sum of elements of an array
- JavaScript Program for Maximize Elements Using Another Array
- Java Program to fill elements in a float array

Advertisements