Home
(current)
About
Tutorial
Technologies
C#
Deep Learning
Statistics for AIML
Natural Language Processing
Machine Learning
SQL -Structured Query Language
Python
Ethical Hacking
Placement Preparation
Quantitative Aptitude
View All Tutorial
Quiz
C#
SQL -Structured Query Language
Quantitative Aptitude
Java
View All Quiz Course
Q & A
C#
Quantitative Aptitude
Java
View All Q & A course
Programs
Articles
Identity And Access Management
Artificial Intelligence & Machine Learning Project
How to publish your local website on github pages with a custom domain name?
How to download and install Xampp on Window Operating System ?
How To Download And Install MySql Workbench
How to install Pycharm ?
How to install Python ?
How to download and install Visual Studio IDE taking an example of C# (C Sharp)
View All Post
Tools
Program Compiler
Sql Compiler
Replace Multiple Text
Meta Data From Multiple Url
Contact
User
Login
Register
FRESHER BELL ALL LANGUAGE ONLINE COMPILER
Java program to find average of numbers in the array
Languages
Java
C
C-99
C++
C++ 14
C++ 17
PHP
Perl
Python 2
Python 3
Ruby
Go Lang
Scala
Bash Shell
SQL
Pascal
C#
VB.NET
Haskell
Objective C
Swift
Groovy
Fortran
Brainf**k
Lua
TCL
Hack
Rust
D
Ada
R Language
Free Basic
Theme
github
xcode
ambiance
monokai
chaos
chrome
Program
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc=new Scanner(System.in); System.out.println("Enter +ve array size"); int n=sc.nextInt(); double arr1[]=new double[n]; double result1= 0.0; //using for loop double result2= 0.0; //using for each loop System.out.println("Enter array elements"); for(int i=0;i<n;i++) { arr1[i]=sc.nextDouble(); } for(int i=0;i<n;i++) { result1 = result1 +arr1[i]; //result1 += arr[i]; } System.out.println("Using For loop Average is "+ result1/n); for (double arr: arr1) { result2 += arr;//result2 = result2 + arr; } System.out.println("Using For each loop Average is "+ result2/n); } }
Run
Clear
Input
4 2 4 6 8
Output
Powered By Fresher Bell™
Similar Program
#
Program
Language
1
Java program to generate right angled triangle or half pyramid using number and for loop
Java
2
Java Method Overriding Example
Java
3
Java program to check whether the user input is leap year or not
Java
4
Alternate Method: Write a java program to find the lcm .Given input in the form of day interval of dinner. Find the day on which they both will lunch together / dinner together.
Java
5
Java program to find the sum of natural number using recursion
Java
6
Java Unary Operator Negating Example
Java
7
Java program to generate right angled triangle or half pyramid using '*' and for loop
Java
8
Java Continue Keyword Example
Java
9
Java program to calculate sum of number from 1 to user input using for loop
Java
10
Java Relational Operator Example
Java
11
Java program to calculate value using base and exponent ( power value ) using for loop
Java
12
Java Interface Example
Java
13
Write a java program to find summation of even numbers in the array
Java
14
Java if else if ladder Example
Java
15
Java program to convert octal to decimal
Java
16
Write a java program to calculate product of count of uppercase and lowercase letters
Java
17
Java Break Keyword Example
Java
18
Write a java program so that odd position char will be in uppercase & even will be lowercase
Java
19
Java program to find quotient and remainder on division by taking input from user
Java
20
Java Program to convert Character to String
Java
#
Program
Language
Copyright © 2020
Inovatik
- All rights reserved