---
title: "Pattern: shrinking \"Programming\""
subject: "Computer Programming"
chapter: 4
key: "semester_1/computer_programming:pattern-programming-shrinking"
source: https://www.bctengineer.com/q/semester_1/computer_programming/pattern-programming-shrinking
site: BCT Engineering
---

# Pattern: shrinking "Programming"

Computer Programming · Chapter 4: Input and Output

- Asked in: 2073 Shrawan, 4 marks
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_1/computer_programming/pattern-programming-shrinking
- Whole chapter: https://www.bctengineer.com/md/semester_1/computer_programming/chapter-4

## Question

Write a C program to display following pattern without using formatted input/output statements.
```
Programming
rogrammin
ogrammi
gramm
ram
a
```

## Short answer

Loop i=0 to 5; inner loop prints characters from index i to 10-i of the string "Programming" using putchar. Each row drops one character from both ends, yielding the shrinking pattern from "Programming" down to "a".

## Answer

Each new row drops one character from the beginning and one from the end of "Programming". Row `i` (starting from 0) prints the characters from index `i` to `10 - i`. The output is done with `putchar()` only.

```c
#include <stdio.h>
int main(void)
{
    char s[] = "Programming";
    int i, j;
    for (i = 0; i < 6; i++)
    {
        for (j = i; j < 11 - i; j++)
            putchar(s[j]);
        putchar('\n');
    }
    return 0;
}
```
Output:
```text
Programming
rogrammin
ogrammi
gramm
ram
a
```

The outer loop runs 6 times (11 characters become 9, 7, 5, 3 and 1); the inner loop prints characters from `s[i]` to `s[10-i]`.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. Each new row removes:
   A. Only the first character
   B. One character from beginning and one from end
   C. Two from the end
   D. Last two from beginning
   Answer: B. 11, 9, 7, 5, 3, 1 characters. (Key point: Row logic)

2. Row i prints characters from index:
   A. i to 10 - i
   B. 0 to i
   C. i to 11
   D. i+1 to 10
   Answer: A. The inner loop runs j from i to 10 - i. (Key point: Index range)

3. How many rows are printed?
   A. 11
   B. 5
   C. 6
   D. 10
   Answer: C. Lengths 11, 9, 7, 5, 3, 1 gives 6 rows. (Key point: Row count)

4. Which output function is used?
   A. printf
   B. putchar
   C. scanf
   D. gets
   Answer: B. Only putchar, for unformatted output. (Key point: Output)

## Related in Computer Programming

- [Pattern: PULCHOWK using unformatted output](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Apattern-pulchowk) — Computer Programming, chapter 4
- [Output of printf statements](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Aprintf-output-a-b) — Computer Programming, chapter 4
- [Formatted and unformatted I/O in FORTRAN](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Afortran-formatted-unformatted-io) — Computer Programming, chapter 11
- [Formatted vs unformatted I/O](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Aformatted-vs-unformatted-io) — Computer Programming, chapter 4, asked 4×
- [Formatted I/O in FORTRAN with syntax](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Afortran-formatted-io-syntax) — Computer Programming, chapter 11
- [Output of arithmetic expression program](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Aoutput-expression-xyz) — Computer Programming, chapter 3

## Related in other subjects

- [Pyramid pattern output program](https://www.bctengineer.com/question.md?key=semester_3%2Fobject_oriented_programming%3Apyramid-program) — Object Oriented Programming, chapter 8
- [Output of e^(−2t)u(t) to a rectangular input](https://www.bctengineer.com/question.md?key=semester_4%2Fsignals_and_systems%3Aconvolution-exponential-rect-input) — Signals and Systems, chapter 5, asked 4×
- [CE configuration input/output characteristics](https://www.bctengineer.com/question.md?key=semester_2%2Fbasic_electronics_engineering%3Ace-npn-characteristics) — Basic Electronics Engineering, chapter 3, asked 3×
- [LTI output for h(t)=e^(-2t), rectangular input](https://www.bctengineer.com/question.md?key=semester_5%2Fdata_communication%3Alti-output-rect-input) — Data Communication, chapter 2, asked 3×
