AF
HomeTagSubmit NotesAsk AnythingLoginSubscribe Us
AF
1. Feel Free to ask and submit anything on Anyforum.in and get satisfactory answer
2. Registration is not compulsory, you can directly login via google or facebook
3. Our Experts are looking for yours ?.



corejava-programming: Program for triangle pattern

java coding for

* 1
*** 3
***** 5
******* 7
***** 5
*** 3
* 1

corejava x 351
programming x 167
Posted On : 2017-03-28 14:36:31.0
profile Raksha - anyforum.in Raksha
2510
up-rate
2
down-rate

Answers


public class Triangle {
public static void main(String[] args) {
int j;
for(int i=0;i<=3;i++){
for(j=0;j<2*i+1;j++){
System.out.print("*");
}
System.out.print(j+"\n");
if(j==7){
printReverse();
}
}
}
public static void printReverse(){
int j;
for(int i=2;i>=0;i--){
for(j=1;j<=2*i+1;j++){
System.out.print("*");
}System.out.print(j-1+"\n");
}
}
}

Posted On : 2017-03-28 21:51:11
Satisfied : 1 Yes  0 No
profile Rishi Kumar - anyforum.in Rishi Kumar
523187021168
Reply This Thread
up-rate
3
down-rate



Post Answer
Please Login First to Post Answer: Login login with facebook - anyforum.in