TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Calculate sum of natural Odd numbers using Java
Senthilvelan Sambamoorthy
Aug 13
2016
Code
620
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
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