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 Even Numbers Using Java
Senthilvelan Sambamoorthy
Aug 13
2016
Code
991
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
ssva18.rar
/* SUM OF EVEN NUMBER */
import
java.io.*;
class
ssva18
{
public
static
void
main(String arg[])
{
long
n=
0
;
System.out.print(
"\nSUM OF EVEN NUMBERS IN BETWEEN 1 & 50\n\n\n"
);
for
(
int
i=
1
;i<=
50
;i++)
{
if
(i%
2
==
0
)
{
System.out.print(
" "
+i);
n=n+i;
}
}
System.out.println(
"\n\n\nSUM OF EVEN NUMBERS BETWEEN 1 & 50 IS : "
+n);
System.out.println(
"\n"
);
}
}
Java