Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • C
  • C Basics
  • C Data Types
  • C Operators
  • C Input and Output
  • C Control Flow
  • C Functions
  • C Arrays
  • C Strings
  • C Pointers
  • C Preprocessors
  • C File Handling
  • C Programs
  • C Cheatsheet
  • C Interview Questions
  • C MCQ
  • C++
Open In App
Next Article:
C Program To Print Character Pyramid Pattern
Next article icon

C Program to Print Continuous Character Pattern

Last Updated : 07 Aug, 2022
Comments
Improve
Suggest changes
Like Article
Like
Report

Here, we will see how to print continuous character patterns using a C program. Below are the examples:

Input: rows = 5
Output:  

A 
B C 
D E F 
G H I J 
K L M N O 

Input: rows = 3
Output:

A 
B C 
D E F 

There are 2 ways to print continuous character patterns in C:

  1. Using for loop.
  2. Using while loop.

Let’s discuss each of these in detail.

1. Using for loop

Approach 1: Using Character

  1. Assign any character to one variable for the printing pattern. 
  2. The first for loop is used to iterate the number of rows.
  3. The second for loop is used to repeat the number of columns. 
  4. Then print the character based on the number of columns and increment the character value at each column to print a continuous character pattern.

Below is the C program to print continuous character patterns using character using for loop:

C




// C program to print continuous
// character pattern using
// character
#include <stdio.h>
int main()
{   
    int i, j;
   
    // Number of rows
    int rows = 3;
   
    // Taking first character of alphabet
    // which is useful to print pattern
    char character = 'A';
   
    // This loop is used to identify
    // number rows
    for (i = 0; i < rows; i++)
    {
        // This for loop is used to
        // identify number of columns
        // based on the rows
        for (j = 0; j <= i; j++)
        {
            // Printing character to get
            // the required pattern
            printf("%c ",character);
           
            // Incrementing character value so
            // that it will print the next character
            character++;
        }
        printf("\n");
    }
    return 0;
}
 
 
Output
A  B C  D E F 

Approach 2:  Converting a given number into a character

  1. Assign any number to one variable for the printing pattern. 
  2. The first for loop is used to iterate the number of rows.
  3. The second for loop is used to repeat the number of columns. 
  4. After entering into the loop convert the given number in to character to print the required pattern based on the number of columns and increment the character value at each column to print a continuous character pattern. 

Below is the C program to print continuous character patterns by converting numbers into a character:

C




// C program to print continuous
// character pattern by converting
// number in to character
#include <stdio.h>
 
// Driver code
int main()
{   
    int i, j;
   
    // Number of rows
    int rows = 5;
   
    // Given a number
    int number = 65;
   
    // This loop is used to identify
    // number of rows
    for (i = 0; i < rows; i++)
    {
        // This loop is used to identify number
        // of columns based on the rows
        for (j = 0; j <= i; j++)
        {
            // Converting number in to character
            char character = (char)(number);
           
            // Printing character to get the
            // required pattern
            printf("%c ", character);
           
            // Incrementing number value so
            // that it will print the next
            // character
            number++;
        }
        printf("\n");
    }
    return 0;
}
 
 
Output
A  B C  D E F  G H I J  K L M N O 

2. Using while loop:

Approach 1: Using character

The while loops check the condition until the condition is false. If the condition is true then enter into a loop and execute the statements. Below is the C program to print continuous character patterns using character:

C




// C program to print the continuous
// character pattern using while loop
#include <stdio.h>
 
// Driver code
int main()
{   
    int i = 1, j = 0;
   
    // Number of rows
    int rows = 5;
   
    // Given a character
    char character = 'A';
   
    while (i <= rows)
    {
        while (j <= i - 1)
        {
            // Printing character to get
            // the required pattern
            printf("%c ",character);
            j++;
           
            // Incrementing character value
            // so that it will print the next
            // character
            character++;
        }
        printf("\n");
 
        j = 0;
        i++;
    }
    return 0;
}
 
 
Output
A  B C  D E F  G H I J  K L M N O 

Time complexity: O(R*R) where R is given no of rows

Auxiliary space: O(1)

Approach 2: Converting a given number into a character

Below is the C program to print a continuous character pattern by converting a given number into a character using a while loop:

C




// C program to print continuous
// character pattern by converting
// number in to character
#include <stdio.h>
 
// Driver code
int main()
{   
    int i = 1, j = 0;
   
    // Number of rows
    int rows = 5;
   
    // Given a number
    int number = 65;
   
    while (i <= rows)
    {
        while (j <= i - 1)
        {
            // Converting number in to character
            char character = (char)(number);
           
            // Printing character to get the
            // required pattern
            printf("%c ",character);
            j++;
           
            // Incrementing number value so
            // that it will print the next
            // character
            number++;
        }
        printf("\n");
 
        j = 0;
        i++;
    }
    return 0;
}
 
 
Output
A  B C  D E F  G H I J  K L M N O 

Time complexity: O(n2) where n is given rows

Auxiliary Space: O(n)



Next Article
C Program To Print Character Pyramid Pattern

L

laxmigangarajula03
Improve
Article Tags :
  • C Language
  • C Programs
  • C Pattern Programs

Similar Reads

  • Pattern Programs in C
    Printing patterns using C programs has always been an interesting problem domain. We can print different patterns like star patterns, pyramid patterns, Floyd's triangle, Pascal's triangle, etc. in C language. These problems require the knowledge of loops and if-else statements. We will discuss the f
    15+ min read
  • C Program For Printing Right Half Pyramid Pattern
    A half-right pyramid consists of rows with sequential stars, numbers or characters arranged in a triangular shape. The first row has one character, the second row has two, and so on. The characters are aligned to the left making it similar to the right-angle triangle. In this article, we will learn
    5 min read
  • C Program to Print Pyramid Pattern
    In C, a pyramid pattern consists of numbers, stars, or alphabets arranged in a triangular shape. In this article, we will learn how to print different shapes of pyramid patterns using C program. Following are the 6 common pyramid patterns: Right Half Pyramid PatternRight half pyramid pattern looks l
    13 min read
  • C Program to Print Number Pattern
    A number pattern involves printing numbers in a specific arrangement or shape, often in the form of a pyramid, triangle, or other geometric shapes. They are great for practicing loops and conditional statements. In this article, we will learn how to print different number patterns in C. Rhombus Numb
    6 min read
  • C Program to Print Continuous Character Pattern
    Here, we will see how to print continuous character patterns using a C program. Below are the examples: Input: rows = 5Output: A B C D E F G H I J K L M N O Input: rows = 3Output: A B C D E F There are 2 ways to print continuous character patterns in C: Using for loop.Using while loop. Let's discuss
    5 min read
  • C Program To Print Character Pyramid Pattern
    Pyramid patterns is a classic logical programming exercise where a triangular looking pattern is printed by treating the output screen as a matrix and printing a given character. In this article, we will explore how to print various alphabet pyramid patterns using C program. Half Pyramid PatternHalf
    4 min read
  • C Program to Print Right Half Pyramid Pattern
    The Right Half Pyramid Pattern is a triangular pattern consists of rows where each row contains an increasing number of characters. The number of characters starts from 1 and increases by 1 in each subsequent row. Characters are aligned to the left, resembling a right-angle triangle with its hypoten
    2 min read
  • C Program To Print Hollow Pyramid Patterns
    The Hollow Pyramid patterns are the variation of pyramid patterns where only the outer edges are filled with characters but the interior is left empty. In this article, we will learn how to print different hollow pyramid patterns. There can be 5 hollow pyramid patterns corresponding to each of the n
    12 min read
  • C Program to Print Cross or X Pattern
    The Cross or X Pattern is a pattern where characters or stars are printed diagonally from top-left to bottom-right and from top-right to bottom-left, forming an "X" shape. In this article, we will learn how to print this pattern using a C program. Program to Print Cross or X Pattern[GFGTABS] Star Cr
    3 min read
  • Programs to print Interesting Patterns
    Program to print the following pattern: Examples : Input : 5Output:* * * * * * * * * ** * * * * * * ** * * * * ** * * ** ** ** * * ** * * * * ** * * * * * * ** * * * * * * * * *This program is divided into four parts. [GFGTABS] C++ // C++ program to print // the given pattern #include<iostream
    15+ min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences