Sum and Average of N Numbers in Java

Here is the simple program for in Java.

Source Code

import java.util.Scanner;
//Write a program to find the sum and average of given n numbers.
public class sum_avg {
    public static void main(String[] args) {
        Scanner in = new Scanner(;
        System.out.println("Enter The Limit: ");
        int n=in.nextInt();
        int sum=0,a;
        for(int i=1;i<=n;i++)
            System.out.println("Enter The Number "+i+": ");
        System.out.println("The sum of given numbers is : "+sum);
        System.out.println("The Average of given numbers is : "+sum/n);
To download raw file Click Here

Basic Programs

Learn All in Tamil © Designed & Developed By Tutor Joes