Star printing program in Java, pattern 4 :
Code for this pattern :
public class test {public static void main(String[] args) {
int count = 0;
int count2 = 5;
for(int i = 0; i<5; i++){
for(int j = 0; j<count; j++){
System.out.print(" ");
}
for(int k = 0; k<2*count2-1; k++){
System.out.print("*");
}
count = count+1;
count2 = count2-1;
System.out.println();
}
}
}
Try this in C.
Post a Comment