Q:

Calculate sum of natural Odd numbers using Java

0

This Program is used to calculate sum of natural odd numbers

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

// SUM OF NATURAL ODD NUMBERS 

class ssvsumnat 
{ 
public static void main(String args[]) 
{ 
int num; 
int sum=0; 
System.out.println("\n\n\n\t\t'''SUM OF NATURAL ODD NUMBERS 501 to 599'''"); 
for(int i=501;i<600;i++) 
{ 
if ((i % 2) == 0); 
sum = sum + i; 
} 
System.out.println("\n\n\tSum of odd numbers between 501 to 599 = " + sum); 
} 
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now