Want to become a Vibe Coder? Join Vibe Coding Training here
x
C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Calculate sum of natural Odd numbers using Java
WhatsApp
Senthilvelan Sambamoorthy
Aug 13
2016
662
0
0
ssvsumnat.rar
// 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;
}
// end of class
System.out.println(
"\n\n\tSum of odd numbers between 501 to 599 = "
+ sum);
}
// end of main function
}
// end of class
Java
Up Next
Calculate sum of natural Odd numbers using Java