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 The Pyramid Program Using Java
Senthilvelan Sambamoorthy
Aug 13
2016
Code
764
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
ssva19.rar
/* PYRAMID */
import
java.io.*;
import
java.lang.Math;
class
ssva19
{
public
static
void
main(String arg[])
throws
IOException
{
int
i,j,k,m,n;
BufferedReader obj=
new
BufferedReader(
new
InputStreamReader(System.in));
System.out.println(
"\n PYRAMID "
);
System.out.println(
" -------"
);
System.out.print(
"\nENTER THE PYRAMID RANGE : "
);
n=Integer.parseInt(obj.readLine());
System.out.println(
"\n"
);
m=n;
for
(i=
1
;i<=n;i++)
{
m--;
for
(j=m;j>=
1
;j--)
System.out.print(
" "
);
for
(j=
1
,k=i%
10
;j<=i;j++,k++)
System.out.print(Math.abs(k%
10
));
for
(j=
2
,k=k-
2
;j<=i;j++,k--)
System.out.print(Math.abs(k%
10
));
System.out.println(
"\n"
);
}
}
}
Java