//Program for triangle Pattern
//Developed by Ahlam Ansari
import java.io.*;
import java.util.*;
class ptrn3
{
public static void main(String ahlam[])
{
int m;
System.out.println("Enter the number of rows");
Scanner sc=new Scanner(System.in);
m=sc.nextInt();
for(int i=0;i<m;i++)
{
for(int j=1;j<m-i;j++)
{
System.out.print(" ");
}
for(int k=1;k<=i;k++)
{
System.out.print("* ");
}
System.out.print("\n");
}
}
}
/*
C:\Documents and Settings\AHLAM\My Documents\Google Drive\My Lectures\Fall\OOPM\
Programs>javac ptrn3.java
C:\Documents and Settings\AHLAM\My Documents\Google Drive\My Lectures\Fall\OOPM\
Programs>java ptrn3
Enter the number of rows
4
*
* *
* * *
C:\Documents and Settings\AHLAM\My Documents\Google Drive\My Lectures\Fall\OOPM\
Programs>
*/
//Developed by Ahlam Ansari
import java.io.*;
import java.util.*;
class ptrn3
{
public static void main(String ahlam[])
{
int m;
System.out.println("Enter the number of rows");
Scanner sc=new Scanner(System.in);
m=sc.nextInt();
for(int i=0;i<m;i++)
{
for(int j=1;j<m-i;j++)
{
System.out.print(" ");
}
for(int k=1;k<=i;k++)
{
System.out.print("* ");
}
System.out.print("\n");
}
}
}
/*
C:\Documents and Settings\AHLAM\My Documents\Google Drive\My Lectures\Fall\OOPM\
Programs>javac ptrn3.java
C:\Documents and Settings\AHLAM\My Documents\Google Drive\My Lectures\Fall\OOPM\
Programs>java ptrn3
Enter the number of rows
4
*
* *
* * *
C:\Documents and Settings\AHLAM\My Documents\Google Drive\My Lectures\Fall\OOPM\
Programs>
*/
No comments:
Post a Comment