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 Numbers That Are Divisible By 8 Of First 100 Natural Numbers Using Java
Senthilvelan Sambamoorthy
Aug 13
2016
Code
927
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
ssvsumnat1.rar
// Sum of numbers that are divisible by 8 of first 100 natural nos
class
ssvsumnat1
{
public
static
void
main(String args[])
{
int
sum =
0
;
System.out.println(
"\n\n\tSum of numbers that are divisible by 8 of first 100 natural nos"
);
System.out.print(
"\t================================================================"
);
for
(
int
i=
1
;i<=
100
;i++)
{
if
(i%
8
==
0
)
sum = sum + i;
}
//end of for
System.out.println(
"\n\n\t\tSUM = "
+ sum);
}
// end of main function
}
// end of class
Java