Write a program to print following outputs
**** *** ** *
sample program:
import java.io.*; import java.util.*; public class TestClass { public static void main(String[] args) { int i,j,x; Scanner obj=new Scanner(System.in); x=obj.nextInt(); for(i=x;i>=1;i--) { for(j=1;j<=i;j++) { System.out.print("*"); } System.out.println(); } } }
Output:
**** *** ** *Tags JAVA languages
Subscribe Our Newsletter
import java.io.*;
ReplyDeleteimport java.util.*;
public class TestClass {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int n = sc.nextInt();
int k=0;
int n1=n;
while(k<n1) {
for(int i=1;i<=n;i++)
{
System.out.print("*");
}
System.out.println();
k++;
n--;
}
}
}