AF
1. Feel Free to ask and submit anything on Anyforum.in and get satisfactory answer
3. Our Experts are looking for yours ?.

# corejava-programming: Program to find out the sum of odd numbers

 write a java program to find the sum of odd numbers from 3 to 200. corejava x 353programming x 169 Posted On : 2014-07-03 19:45:13.0 prince haxor 1930 3 First traverse all the numbers from 3 to 200 using for loop. and take a variable to store the sum and add the numbers while traversing. Following is the working java code to calculate the sum of odd numbers from 3 to 200. SumOdd.java: ---------------------------- class SumOdd{ public static void main(String s1[]){ int sum=0;//variable to store the sum //Just traverse all the odd numbers from 3 to 200 using for loop for(int i=3;i<=200;i++){ if(i%2 != 0){ //checks no. is not even sum=sum+i; } } System.out.print("The sum of all odd numbers from 2 to 200 = "+sum); } } Posted On : 2014-07-03 22:07:08 Satisfied : 1 Yes  0 No Rishi Kumar 523188250050Reply This Thread 5 