problem solution is an integral part of any programming language we any one
want to join new job then firstly face an interviews because never hire any anyone
without testing their coding abilities .basically in interviews tells some general
problems like patterns and some other questions.in this post we are providing some
important pattern solution that help you in java programming .these pattern solution
also help ICSE IXTH AND XTH AND XITH AND XIITH class students .In ICSE Bord
exam always test with patterns problems.
how print a triangle patterns in java programing
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package patterns;
/**
*
* @author rajesh kumar shukla
*/
public class pattern1 {
public static void printStars(int n)
{
int i, j;
for(i=0; i<n; i++)
{
for(j=0; j<=i; j++)
{
System.out.print("* ");
}
System.out.println();
}
}
public static void main(String args[])
{
int n = 5;
printStars(n);
}
}
output:
run:
*
* *
* * *
* * * *
* * * * *
0 comments:
Post a Comment