Created
October 22, 2017 22:13
-
-
Save MukulLatiyan/c9835a313be2b4dbe84d620f8b5fbb54 to your computer and use it in GitHub Desktop.
Average(GeeksForGeeks)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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