Wednesday, 3 September 2014

program for parscal tiangle, parscal triangle in java, simple parscal program in core java, parscal program using for loop, parscal trangle program using for loop and if condition

/*  This Program is parscal Triangle   output :- 1

11
121
1331
14641  
*/


class ParscalTriangle
{
public static void main (String arg[])
{
int r,value,n;
n=Integer.parseInt(arg[0]);
for(int i=0; i<=n; i++)
{           
           r = i+1;
           value = 1;             
         
for(int c=0; c<=i; c++)
                     {
              
              if(c>0)
              {
                  value = value * (r - c) / c;                    
              }                
              System.out.print(value + " ");                    
           }
           System.out.println();
       }
}
}

0 comments:

Post a Comment

 
Copyright © . StackOverflow - Posts · Comments
· Powered by Sanjay Chauhan