Computer Science, asked by ah3019153, 7 hours ago

Write a java program to find the sum and average of first 10 odd numbers​

Answers

Answered by atrs7391
0

public class Main {

   public static void main(String[] args) {

       int sum = 0;

       for (int i = 1; i <= 20; i++) {

           if (i%2 == 1) {

               sum += i;

           }

       }

       System.out.println("Sum of first 10 odd numbers: " + sum + "\nAverage of first 10 odd numbers: " + sum/10);

   }

}

Similar questions