Q-4-Write a java program to print an equilateral triangle using star ' * '.
INPUT :
public class NCM {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println(" * ");
System.out.println(" * * ");
System.out.println(" * * * ");
System.out.println(" * * * * ");
System.out.println(" * * * * * ");
System.out.println(" * * * * * * ");
System.out.println(" * * * * * * * ");
System.out.println(" * * * * * * * * ");
}
}
INPUT :
public class NCM {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println(" * ");
System.out.println(" * * ");
System.out.println(" * * * ");
System.out.println(" * * * * ");
System.out.println(" * * * * * ");
System.out.println(" * * * * * * ");
System.out.println(" * * * * * * * ");
System.out.println(" * * * * * * * * ");
}
}
OUTPUT :
*
* *
* * *
* * * *
* * * * *
* * * * * *
* * * * * * *
* * * * * * * *
No comments:
Post a Comment