Practical 10


Aim:- Write an interactive program to print a diamond shape. For example, if user enters the number 3, the diamond will be as follows:
* * *
* *
*

JAVA Code :-

import java.lang.*;

class pra10
{
  public static void main(String args[])
  {
    int i,j,n;

    n=Integer.parseInt(args[0]);   
    
    for(i=n;i>0;i--)
    {
      for(j=n;j>0;j--)
      {
           if(i<j)
               System.out.print(" ");
         else
               System.out.print("* ");
      }
       System.out.println();
    }
  }
}

Output:-



No comments:

Post a Comment

Programs

Home Aim:- Write a program to convert rupees to dollar. (60rupees=1 dollar). Aim:- Write a program that calculate percentage marks...