Computer Science, asked by kodyjesse11, 4 days ago

Write a basic program to find the sum of the odd number from 9 to 300​

Answers

Answered by samarthkrv
0

Answer:

public class Main

{

public static void main(String[] args) {

    int sum = 0;

 for(int i = 8; i < 300; i++)

     {

         if(i%2==1)

             {

             sum = sum + i;  

             }

     }

     System.out.println("The sum of odd numbers from 9 to 300 is:" + sum);

}

}

Explanation:

The output is -

The sum of odd numbers from 9 to 300 is:22484

Answered by edwinshajumalakaranc
0

Answer:

x=9

y=300

z=0

for i in range(x,y+1,2):

   z+=i

print("sum of the odd number between 9 and 300 is", z)

Similar questions