Advertisement
Waliullah8328

Sumation Of Array

Feb 2nd, 2021
979
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.63 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class SumationOfArray {
  6.     public static void main(String[] args) {
  7.         Scanner input = new Scanner(System.in);
  8.         int n,i;
  9.         int sum =0;
  10.         System.out.print("Enter How Many Number You Want To Insert : ");
  11.         n = input.nextInt();
  12.         int arr[] = new int [n];
  13.  
  14.         System.out.println("Enter Your "+n+ " Numbers");
  15.         for(i = 0;i < n; i++)
  16.         {
  17.             arr[i]= input.nextInt();
  18.         }
  19.  
  20.         for(i = 0; i<n; i++)
  21.         {
  22.             sum = sum + arr[i];
  23.     }
  24.         System.out.println("Sumation : "+sum);
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement