Programming Exercises

  1. Write a program that creates an array with 26 elements and stores the 26 lowercase letters in it. Also have it show the array contents.

  2. Use nested loops to produce the following pattern:

    $
    $$
    $$$
    $$$$
    $$$$$
    
  3. Use nested loops to produce the following pattern:

    F
    FE
    FED
    FEDC
    FEDCB
    FEDCBA
    
  4. Have a program request the user enter an uppercase letter. Use nested loops to produce a pyramid pattern like this:

        A
       ABA
      ABCBA
     ABCDCDA
    ABCDEDCBA
    

    The pattern should extend to the character entered. For instance, the preceding pattern would result from an input value of E. Hint: Use an outer loop to handle the rows. Use three inner loops in a row, one to handle the spaces, one for printing letters in ascending order, and one for printing letters ...

Get C Primer Plus®, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.