0% found this document useful (0 votes)
17 views3 pages

C Program for Pattern Printing

The document provides a C program that prints a specific pattern using the string 'CPROGRAM'. It first prints an increasing sequence of characters from the string followed by a decreasing sequence, creating a symmetrical pattern. The program utilizes nested loops to achieve this output.

Uploaded by

harshaindra01
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views3 pages

C Program for Pattern Printing

The document provides a C program that prints a specific pattern using the string 'CPROGRAM'. It first prints an increasing sequence of characters from the string followed by a decreasing sequence, creating a symmetrical pattern. The program utilizes nested loops to achieve this output.

Uploaded by

harshaindra01
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

1. Develop a C program to print the following pattern.

CP

CPR

CPRO

CPROG

CPROGR

CPROGRA

CPROGRAM

CPROGRA

CPROGR

CPROG

CPRO

CPR

CP

#include <stdio.h>
#include <string.h>

int main() {

char str[] = "CPROGRAM";

int len = strlen(str);

// Increasing pattern

for (int i = 1; i <= len; i++) {

for (int j = 0; j < i; j++) {

printf("%c", str[j]);
}

printf("\n");

// Decreasing pattern

for (int i = len - 1; i >= 1; i--) {

for (int j = 0; j < i; j++) {

printf("%c", str[j]);

printf("\n");

return 0;

Output:
C
CP
CPR
CPRO
CPROG
CPROGR
CPROGRA
CPROGRAM
CPROGRA
CPROGR
CPROG
CPRO
CPR
CP
C

You might also like