Thread: Pascal's Triangle w/letters.

  1. #1
    Registered User
    Join Date
    Aug 2011
    Posts
    2

    Pascal's Triangle w/letters.

    Hi I am new to C++ and I'm still at the learning stage.
    I have been racking my brains on this program, Pascal's Triangle using letters.

    e.g:

    F
    FE
    FED
    FEDC
    FEDCB
    FEDCBA

    I have the code worked out but I get ASCII characters instead of letters.
    If some one can just point me in the right direction that would be great.

    Code:
    #include<iostream> 
    using namespace std; 
     
    int main() 
    { 
        int col, row; 
        char lett; 
         
     
         
          cout << "Please enter letter:  "; 
          cin >> lett; 
             
        for (col = 0; col <= 6; col++) 
        { 
                                  
            for (lett = 0; lett <= col; lett++) 
                  
                                           
                cout << lett; 
                cout << endl; 
        } 
         
        system ("PAUSE"); 
        return 0; 
         
    }
    Attached Files Attached Files
    Last edited by Salem; 08-05-2011 at 11:58 PM. Reason: Pasted code inline

  2. #2
    Registered User
    Join Date
    May 2011
    Location
    Around 8.3 light-minutes from the Sun
    Posts
    1,949
    Code:
      cout << "Please enter letter:  ";
          cin >> lett;
            
        for (col = 0; col <= 6; col++)
        {
                                 
            for (lett = 0; lett <= col; lett++)
                 
                                          
                cout << lett;
                cout << endl;
        }
    Did you look at your second for loop? What are you doing with lett?

    EDIT: The standard is to actually post code here with code tags. Most people will not open attachements.
    Quote Originally Posted by anduril462 View Post
    Now, please, for the love of all things good and holy, think about what you're doing! Don't just run around willy-nilly, coding like a drunk two-year-old....
    Quote Originally Posted by quzah View Post
    ..... Just don't be surprised when I say you aren't using standard C anymore, and as such,are off in your own little universe that I will completely disregard.
    Warning: Some or all of my posted code may be non-standard and as such should not be used and in no case looked at.

  3. #3
    Registered User
    Join Date
    Aug 2011
    Posts
    2
    I figured out my problem, my apologies... and next time I have a problem I will post my code properly with code tags.

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 Unregistered in forum C++ Programming
    Replies: 2
    Last Post: 02-22-2002, 01:34 PM

Tags for this Thread