Go to Top

Tuesday, 21 February 2012

Visitor's Request - 6

Hello Harish !

You had asked for the program to print the Pascal's Triangle, which is :


1 1 
1 2 1 
1 3 3 1 
1 4 6 4 1 

Here's your program.

Java Program :

class pattern_44
{
 static void print(int b)
 {
     int[] a=new int[b];
     a[0]=1;
     int i,j,k;
     for(i=0;i<b;i++)
     {
         for(j=i-1;j>=0;j--)
         a[j+1]=a[j+1]+a[j];
         for(k=0;k<=i;k++)
         System.out.print(a[k]+" ");
         System.out.print("\n");
        }
    }
}

I would be a bit busy for this month, owing to my ICSE exams, but in case you have any more queries, be sure to communicate them to me. I would certainly try to solve it in my free time.

20 comments:

  1. EXCUSE ME PROGRAMMER CAN U GIVE RESULT OF THIS PATTERN:

    14442
    31425
    33155
    32615
    26661

    ReplyDelete
  2. it can also be simply done by printing 11 raised to the power 0 then 1 and 2 and 3 and so on...
    in short 11 raised to the power i
    and i loop 0 - 4
    am i right??

    ReplyDelete
  3. Can ayone plese hep me with this pattern. If array is to be used, then use single dimensional array please.
    RRRRRRRRR
    ROOOOOOR
    ROHHHHOR
    ROH I I I HOR
    ROH I T I HOR
    ROH I I I HOR
    ROHHHHOR
    ROOOOOOR
    RRRRRRRRR

    ReplyDelete
  4. Thanks for Information Java is an object-oriented programming language with a built-in application programming interface (API) that can handle graphics and user interfaces and that can be used to create applications or applets. There are many websites and lots of applications that will not work unless you have Java installed, and more are created every day. Java is the fast, secure and more reliable. Java applications are used everywhere from laptops to datacenters, game consoles to scientific supercomputers, cell phones to the Internet etc. JAVA Online Training

    ReplyDelete
  5. please solve this programme
    $
    ???
    >>>>>
    <<<<<<<<
    #########

    ReplyDelete
  6. you can also try this for executing the pascal triangle ,this is an easier version . ...................
    class pattern11{
    public static void main (){
    for (int i=1;i<=4;i++){
    for (int j=1;j<=i;j++){
    double a=Math.pow(11,i);
    System.out.print(a);}
    System.out.println();}
    }}

    ReplyDelete
  7. nice article. And interesting topic on Java Programming. Keep posting more articles with examples on Java. Thank You.

    ReplyDelete
  8. This comment has been removed by the author.

    ReplyDelete
  9. hey!can u give me program of spy number using function

    ReplyDelete
  10. His subject is good, long while I find this topic and I think it is here, many thanks guys . ICSE 10th Time Table 2018
    Rajasthan Board 10th Result

    ReplyDelete
  11. Nice blog..! I really loved reading through this article... Thanks for sharing such an amazing post with us and keep blogging...
    ios app development course

    ReplyDelete
  12. Thanks for sharing amazing information !!!!!!
    Please keep up sharing.

    ReplyDelete

ShareThis