Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main (String[] args)
- {
- int n , sum = 0, even=0,odd=0, average=0, avcount = 0 ;
- Scanner s = new Scanner (System.in);
- System.out.print("Enter no. of elments in array ");
- n = s.nextInt();
- int a[] =new int[n];
- for(int i=0; i<n;i++){
- a[i]=i;
- sum = sum +i;
- if (i%2==0){
- even +=1;
- }
- else
- {
- odd+=1;
- }
- }
- average = sum/n ;
- System.out.println("Sum of all the array elements is "+sum);
- System.out.println("The average of the array elements is"+average);
- System.out.println("The number of even numbers in the array is "+even);
- System.out.println("The number of odd numbersw in the array is "+odd);
- for (int j =0; j<n;j++){
- a[j]=j;
- if (j>=average){
- avcount +=1;
- }
- }
- System.out.println("The number of elements grater than the average is "+avcount);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement