Java

Calculate sum of natural Odd numbers using Java

Calculate sum of natural Odd numbers using Java
// 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); 
} 
}
Senthilvelan Sambamoorthy

Senthilvelan Sambamoorthy is working as a Professor in Department of Master of Computer Applications, Paavai Engineering College, Namakkal, Tamilnadu, India, He is Masters in Computers Applications. Having 18+ years of experience and his area of interest is Java, JSP, Servlet, J2EE, C#, PHP, Python ASP.NET, SQL Server and etc.