Skip to content

Instantly share code, notes, and snippets.

@MukulLatiyan
Created October 22, 2017 22:13
Show Gist options
  • Save MukulLatiyan/c9835a313be2b4dbe84d620f8b5fbb54 to your computer and use it in GitHub Desktop.
Save MukulLatiyan/c9835a313be2b4dbe84d620f8b5fbb54 to your computer and use it in GitHub Desktop.
Average(GeeksForGeeks)
//Java Code SOlution of Average named problem in geeksforgeeks school array section
import java.util.*;
import java.lang.*;
import java.io.*;
class GFG {
public static void main (String[] args) {
Scanner in = new Scanner(System.in);
int t = in.nextInt();
while (t-- > 0){
int n = in.nextInt();
int total = 0;
int average = 0;
for (int i = 1; i <= n; i++) {
int temp = in.nextInt();
total += temp;
average = total / i;
System.out.print(average + " ");
}
System.out.println();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment