Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5995261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:56:06+00:00 2026-05-22T23:56:06+00:00

Have a program request the user to enter an uppercase letter. Use nested loops

  • 0

“Have a program request the user to enter an uppercase letter. Use nested loops to produce a pyramid pattern like this:

    A

   ABA

  ABCBA

 ABCDCBA

ABCDEDCBA

The pattern should extend to the character entered. For example, the preceding pattern would result from an input value of E.”

So far I’ve been doing this for a good few hours and I’m getting the ‘pyramid’ to format properly for the letters when iterating forwards through the alphabet with:

#include <stdio.h>
int main(void)
{
    char ch = 0;
    char ch2 = 0;
    int rows = 0;
    printf("Enter a character: ");
    scanf("%c", &ch);
    rows = ch - 64;
    while(rows > 0)
    {
        int spaces;
        for(spaces = rows-1; spaces > 0; spaces--)
        {
            printf(" ");
        }
        ch2 = 65;
        while(ch2 < (ch-(rows-2)))
        {
            printf("%c", ch2);
            ch2++;
        }

        printf("\n");
        rows--;
    }
}

However, I feel as though I’ve hit a brick wall with trying to get it to iterate backwards properly. I know it should only be a few basic loops but I’m well and truly stuck. I’m sure it’s easy… I think I’ve just been looking at it too long. Ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T23:56:06+00:00Added an answer on May 22, 2026 at 11:56 pm

    You are so close, you only need to take a breath and you’ll see it.

    When you print out your character, it has to be done after this part

        while(ch2 < (ch-(rows-2)))
        {
            printf("%c", ch2);
            ch2++;
        }
    

    or it won’t fall at the end of the string. What you need is another loop that starts at the character that’s one below the last character printed. It should print a character and decrement that character until it has printed the ‘A’ character.

    Since this is homework, I’ll give you a chance to write that loop before telling you the exact details.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a program that's creating a secure directory for user output. This is
hi I have a scenario like this I made a chat program where a
Let's say I have a java program that makes an HTTP request on a
I have a program that creates a Windows user account using the NetUserAdd() API
How can I request the user to input the filename that my program needs
I'm making a program for registration on a website. For this, I use C++Builder
so if you have a favorite button like on SO, then the user could
Let's say I have a multithreaded C++ program that handles requests in the form
I have a program that spits out both standard error and standard out, and
I have a program that uses the mt19937 random number generator from boost::random. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.