Thread: Code for pascal triangle

  1. #1
    Registered User
    Join Date
    Jan 2011
    Posts
    113

    Code for pascal triangle

    Could you please give algorithm for printing pascal triangle when an input number is taken which defines number of lines of pascal triangle that it has to print..

    don't give me the code directly .. but help me how to crack it...

  2. #2
    Registered User
    Join Date
    Nov 2004
    Location
    USA
    Posts
    516
    Have you first tried printing the triangle values without the formatting?
    Code:
    >+++++++++[<++++++++>-]<.>+++++++[<++++>-]<+.+++++++..+++.[-]>++++++++[<++++>-] <.>+++++++++++[<++++++++>-]<-.--------.+++.------.--------.[-]>++++++++[<++++>- ]<+.[-]++++++++++.

  3. #3
    Registered User
    Join Date
    Jan 2011
    Posts
    113
    I tried but i am not getting them ..

  4. #4
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by suryak View Post
    I tried but i am not getting them ..
    Then post your code... lets see what's going on....

  5. #5
    Registered User
    Join Date
    May 2011
    Posts
    2
    <<< link to spoon-fed homework snipped >>>
    visit this link you will get the code

  6. #6
    Registered User
    Join Date
    May 2010
    Location
    Naypyidaw
    Posts
    1,314
    Stop giving code. You are not helping anyone.

  7. #7
    Registered User
    Join Date
    May 2011
    Posts
    2
    Quote Originally Posted by Bayint Naung View Post
    Stop giving code. You are not helping anyone.
    thats fine sorry

  8. #8
    Registered User
    Join Date
    Sep 2008
    Location
    Toronto, Canada
    Posts
    1,834
    Pascal's triangle are just rows of sums of the previous row's numbers. Or, each element can be calculated from its X,Y coordinate using factorials. Depending on what you've learned in math.
    Binomial coefficient - Wikipedia, the free encyclopedia
    The formatting of a nice triangular picture of numbers requires printing spaces and ensuring the numbers all have fixed width and/or are centered. So that's the 2nd part of the problem.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Pascal's Triangle
    By ijlalhayder in forum C Programming
    Replies: 1
    Last Post: 01-14-2011, 10:27 AM
  2. pascal's triangle
    By Priyank in forum C Programming
    Replies: 9
    Last Post: 01-14-2011, 10:25 AM
  3. Pascal Triangle
    By illidari in forum C Programming
    Replies: 3
    Last Post: 05-03-2010, 09:44 PM
  4. pascal triangle
    By siavoshkc in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 07-25-2006, 01:21 PM
  5. pascal triangle
    By ndukaa1 in forum C++ Programming
    Replies: 15
    Last Post: 10-05-2004, 10:40 PM

Tags for this Thread