I am a beginner in pattern programming. Please check this pattern and tell me whether it's correct or not and also if incorrect please attach the correct program with your answer. thankyou *irrelevant and rubbish answers will be reported*
Answers
Given Pattern:-
1 * * * * *
2 * * * *
3 * * *
4 * *
5 *
6
Your Program is correct but contains one errorIn J loop, you should write j<=i-1 not j=i-1.
Corrected Program:-
public class CheckCóde {
public static void main(String ar []){
for(int I=1;I<=6;I++){
for(int j=1;j<=I-1;j++)
System.out.print(" ");
System.out.print(I);
for(int k=5;k>=I;k--)
System.out.print("*");
System.out.println();
}
}
}
_
•Output Attached
♬•••♪
Pattern / Output:
Please Check Attachment!
Program:
public static void main(String[] args) {
for(int i=1; i<7; i++) {
for(int j=1; j<=i-1; j++) {
System.out.print(" ");
}
System.out.print(i);
for(int i2=5; i2>=i; i2--) {
System.out.print("*");
}
System.out.println();
}
}
}