Mode Gelap

Recent in Fashion

Best Seller Books

1311110003 Input and Output Statement Star Pattern

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:
****
***
**
* 

Subscribe Our Newsletter

avatar
"By speaking behind my back, it means that you respect my existence enough not to act in front of my face."

Related Posts

1 Komentar

  1. import java.io.*;
    import 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--;
    }
    }
    }

    ReplyDelete

Article Top Ads

Parallax Ads

Article Center Ads

Article Bottom Ads