Advertisement
Shekhar777

Java Loops and Introduction to Arrays - Post Class - Sum and Mean

Oct 19th, 2020
535
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.32 KB | None | 0 0
  1. Q17-Given an array A[] of size N, containing positive integers. You need to print the sum and mean (floor value) of given numbers.
  2. Ans-static void SumAndMean(int arr[],int N){
  3.   int Sum=0;
  4.   int mean;
  5.   for(int i=0;i<N;i++)
  6.   {
  7.     Sum=Sum+arr[i];
  8.   }
  9.    mean =(Sum/N);
  10.    System.out.println(Sum + " " + mean);
  11. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement