Like Tree2Likes
  • 2 Post By AndrewHunter

Pascal's Triangle w/letters.

This is a discussion on Pascal's Triangle w/letters. within the C++ Programming forums, part of the General Programming Boards category; Hi I am new to C++ and I'm still at the learning stage. I have been racking my brains on ...

  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-06-2011 at 12:58 AM. Reason: Pasted code inline

  2. #2
    Registered User
    Join Date
    May 2011
    Location
    Around 8.3 light-minutes from the Sun
    Posts
    1,866
    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.
    Salem and iMalc like this.
    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, 10:44 PM
  4. pascal triangle
    By siavoshkc in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 07-25-2006, 02: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


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21