C# Corner
Tech
News
Videos
Forums
Trainings
Books
Live
More
Interviews
Events
Jobs
Learn
Career
Members
Blogs
Challenges
Certifications
Bounties
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 The Pyramid Program Using Java
WhatsApp
Senthilvelan Sambamoorthy
Aug 13
2016
889
0
0
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
Up Next
Calculate The Pyramid Program Using Java