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

  • SEARCH
  • Home
  • 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 4616926
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:03:07+00:00 2026-05-22T02:03:07+00:00

I have to display this number pattern: -3 1 5 9 7 12 17

  • 0

I have to display this number pattern:

-3  1  5  9
7  12  17
15 21

using:

int number = __________________; // assign correct initial value
int row, col;

for (row = 1; row <= 3; row++)
{
    // adjust number so it displays the correct first value in the row
    ________________________________________________
    for (col = 1; col <= ___5 - row___; col++)
    {
      cout << setw (5) << number;

     // adjust number so it displays the next correct value in this row 
    ______________________number + row + 3;_________________________________ 
        } / /end inner for loop
 cout << endl;
 } // end outer for loop

I know number + row + 3 gets the correct numbers across but I cannot seem to get the correct start value.

  • 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-22T02:03:07+00:00Added an answer on May 22, 2026 at 2:03 am

    Try this

    number = -3
    
    for(row = 1; row <= 3; row++){
       for (col = 0; col < 5 - row; col ++){
           display (number + col * (3 + row));
       }
       number += 12 - row * 2;
    }
    

    With your restrictions, that would be:

    int number = 0; // assign correct initial value
    int row, col;
    
    for (row = 1; row <= 3; row++)
    {
        // adjust number so it displays the correct first value in the row
        number += 12 - (row-1) * 2 - (row+2) * (6 - row);
    
        for (col = 1; col <= 5 - row; col++)
        {
            cout << setw (5) << number;
    
            // adjust number so it displays the next correct value in this row 
            number = number + row + 3;
        } / /end inner for loop
        cout << endl;
     } // end outer for loop
    

    Explanation:

    (not a bullet) + [12 – (row-1)*2] is for moving between -3, 7 and 15

    (not a bullet) – [ ((row-1) + 2) * (5 – (row – 1))] is for compensating growth of the number in the internal loop

    Since the result of the right part with row = 1 is -3, initial number is chosen as 0.

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

Sidebar

Related Questions

I have the following number: 4.3 I'd like to display this number as 4,3
I have several unordered lists that I want to display like this: <ul> <li><img></li>
I am trying to have a tree display custom data that looks like this.
I have an HTML along the following lines: <div class=hiddenClass> // this implies display:none
I have this situation where I want to display a list of Administration objects
I have this mysql tables I want to display with jqgrid. The problem appears
I have this piece of code I'm trying to get to display but no
I have the need to display a date in this format: dd/mm/yyyy. This is
I have this div: <div class=inauguration-image> I do not want this text to display,
I have an SQL table like this : sales(product,timestamp) I want to display a

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.