Powers of 11 Pattern in C++

Beginner
⏱️ 6 min read
📚 Updated: Aug 2025
🎯 2 Code Examples
Loops

What You’ll Learn

How to print a simple numeric pattern where each row is multiplied by 11:

1, 11, 121, 1331, 14641.

This is a quick loop exercise and also a fun math pattern for beginners.

⭐ Pattern Output

For 5 rows, the pattern looks like this:

Output
1
11
121
1331
14641
1

Complete C++ Program

Start with 1 and multiply the running result by 11 on each next row.

C++
#include <iostream>
using namespace std;

int main() {
    int i, res = 1;

    for (i = 1; i <= 5; i++) {
        if (i == 1)
            res = i;
        else
            res = res * 11;

        cout << res;
        cout << "\n";
    }

    return 0;
}

🧠 How It Works

1

Initialize the result

We start with res = 1.

Setup
2

Loop over rows

The loop runs from i = 1 to 5 and prints one value per row.

Loop
3

Multiply by 11

From the second row onward, we compute res = res * 11.

Update
4

Print the value

We output res and print a newline to move to the next row.

Output
=

Powers of 11

This is a fast pattern to generate because each row is a single multiplication.

2

Variation — User Input Version

Let the user choose the number of rows. This version uses long long to reduce overflow risk (but it still overflows for larger rows).

C++
#include <iostream>
using namespace std;

int main() {
    int rows;
    cout << "Enter the number of rows: ";
    cin >> rows;

    if (rows <= 0) return 0;

    long long res = 1;
    for (int i = 1; i <= rows; i++) {
        if (i == 1) res = 1;
        else res = res * 11;
        cout << res << "\n";
    }

    return 0;
}

💡 Tips for Enhancement

Try These

  • Use unsigned long long for a slightly larger range
  • Use big integers (or strings) if you want many rows without overflow
  • Print the values with commas for readability
  • Compare these values to Pascal’s triangle for the first few rows
  • Add overflow checks before multiplying by 11

Avoid

  • Printing many rows with int (overflow happens quickly)
  • Assuming the digits always match Pascal’s triangle (carry changes later rows)
  • Not handling invalid input when reading rows
  • Using endl inside loops (unnecessary flushing)

Key Takeaways

1

Each next row is the previous value multiplied by 11.

2

Early rows match Pascal’s triangle digits (before carry starts).

3

Values overflow quickly in fixed-width integer types.

4

Time complexity is O(n) for n rows.

❓ Frequently Asked Questions

Because we begin with res = 1 and print it as the first row.
It’s the normal multiplication result: 1331 * 11 = 14641.
Because of carry operations during multiplication. After a few rows, the digits no longer remain single coefficients.
O(n) because we do one multiplication and one print per row.

Explore More C++ Number Patterns!

Patterns like this connect programming practice with neat math shortcuts—try experimenting with other multipliers too.

All Number Patterns →
Did you know?

The first few powers of 11 visually encode binomial coefficients (Pascal’s triangle) before carry operations kick in.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

12 people found this page helpful