Program: 7
Output:public class HelloWorld{ public static void main(String []args){ for(int i=19;i>0;i-=2){ for(int k=i;k<20;k+=2) System.out.print(" "); for(int j=0;j<i;j++){ System.out.print("*"); } System.out.println(""); } } }
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Program: 8
public class HelloWorld{public static void main(String []args){for(int i=0;i<11;i++){for(int j=0;j<10;j++){if((j<(0+((11/2)-(i)))) || (j>=(11-((11/2)-(i-1)))))System.out.print("*");elseSystem.out.print(" ");}System.out.println("");}}}
No comments:
Post a Comment