Pattern Program in C Language

By | June 16, 2016

List of Pattern Program in C Programming Language

Learn How To Print Pattern Program in C Programming Language. It is important that you should understand How A For Loop Works in C Programming before going further with this C Program To Generate Patterns of Numbers.

Note: This Java Program to Print Pattern Programs is edited with gEdit Editor and executed using Terminal in Linux Ubuntu Operating System.


Pattern 1: C Program To Print Pattern of Numbers using While Loop

1 2 3 4 5
5 4 3 2
2 3 4
4 3
3

#include<stdio.h>

int main()
{
    int temp = 1, limit, m;
    int count = 1;
    printf("Enter A Limit:\t");
    scanf("%d", &limit);
    while(limit > 0)
    {
        m = limit;
        while(m--)
        {
            printf("%d", count);
            count = count + temp;
        }
        printf("\n");
        temp = temp * (-1);
        count = count + temp;
        limit--;
    }
    return 0;
}

Output

Print Pattern Program in C

Pattern 2: C Program To Print Characters in Pattern using For Loop

ABCDDBCA
ABC      CBA
AB            BA
A                 A

#include<stdio.h>

int main()
{
    int count, b, c, d;
    printf("\n");
    for(count = 0; count <= 4; count++)
    {
        for(b = 0; b < 4 - count; b++)
        {
            printf("%c", 65 + b);
        }
        if(count >= 0)
        {
                for(c = 0; c <= 2*count-1; c++)
            {
                    printf(" ");
            }
        }
        for(d = 3 - count; d >= 0; d--)
        {       
            if(d <= 3)
            {
                printf("%c", 65 + d);
            }
        }
        printf("\n");
    }
    printf("\n");
    return 0;
}

Output

Code To Develop Pattern Programs in C

If you have any compilation error or doubts in this Code For Printing Pattern Program in C Programming, let us know about in the comment section below.

Recommended Programs
1Convert Binary To Decimal Number in C Programming
2C Program To Generate Fibonacci Series using Recursion
3Sum of Series: 1+ 1/2 + 1/3 + 1/4 + …. + 1/n
4C Program For Encryption and Decryption of a Text File
5C Program To Print Map of India
6100+ C Programs For Programming Interviews

8 thoughts on “Pattern Program in C Language

  1. Suresh Pandule

    kaise to kiya he just check it

    static void Main(string[] args)
    {
    int row,count,refcount=1,count1,refcount1=4,count2,refcount2=3,count3,refcount3=2;
    Console.Write(“Enter the No of Rows You Want”);
    row = Int32.Parse(Console.ReadLine());

    for (int i = 1; i <= row; i++)
    {
    count3 = refcount3;
    count2 = refcount2;
    count1=refcount1;
    count=refcount;

    if (i <= 3)
    {
    for (int j = 1; j 0)
    {
    Console.Write(“*”);
    }
    else if (count1– > 0)
    {
    Console.Write(“#”);
    }
    }
    else
    {
    if (count1– > 0)
    {
    Console.Write(“#”);
    }
    else if (count– > 0)
    {
    Console.Write(“*”);
    }
    }

    }
    Console.WriteLine();
    ++refcount;
    –refcount1;
    }
    else
    {
    for (int j = 1; j 0)
    {
    Console.Write(“#”);
    }
    else if (count3– > 0)
    {
    Console.Write(“*”);
    }
    }
    else
    {
    if (count3– > 0)
    {
    Console.Write(“*”);
    }
    else if (count2– > 0)
    {
    Console.Write(“#”);
    }
    }

    }
    Console.WriteLine();
    ++refcount2;
    –refcount3;
    }

    } Console.ReadKey();
    }

    Reply
  2. Suresh Pandule

    kaise to kiya he maine

    static void Main(string[] args)
    {
    int row,count,refcount=1,count1,refcount1=4,count2,refcount2=3,count3,refcount3=2;
    Console.Write(“Enter the No of Rows You Want”);
    row = Int32.Parse(Console.ReadLine());

    for (int i = 1; i <= row; i++)
    {
    count3 = refcount3;
    count2 = refcount2;
    count1=refcount1;
    count=refcount;

    if (i <= 3)
    {
    for (int j = 1; j 0)
    {
    Console.Write(“*”);
    }
    else if (count1– > 0)
    {
    Console.Write(“#”);
    }
    }
    else
    {
    if (count1– > 0)
    {
    Console.Write(“#”);
    }
    else if (count– > 0)
    {
    Console.Write(“*”);
    }
    }

    }
    Console.WriteLine();
    ++refcount;
    –refcount1;
    }
    else
    {
    for (int j = 1; j 0)
    {
    Console.Write(“#”);
    }
    else if (count3– > 0)
    {
    Console.Write(“*”);
    }
    }
    else
    {
    if (count3– > 0)
    {
    Console.Write(“*”);
    }
    else if (count2– > 0)
    {
    Console.Write(“#”);
    }
    }

    }
    Console.WriteLine();
    ++refcount2;
    –refcount3;
    }

    } Console.ReadKey();
    }

    Reply
  3. Suresh Pandule

    Output:-

    &#######
    #######&&
    &&&######
    #####&&&&
    &&&&&####
    #####&&&&
    &&&######
    #######&&
    &#######

    class Program
    {
    static void Main(string[] args)
    {
    int center_row, row,count,refcount=1,count1,refcount1,count2,refcount2,count3,refcount3;

    Console.Write(“Enter the No of Rows You Want”);
    row = Int32.Parse(Console.ReadLine());
    center_row = (row / 2) + 1;
    refcount1 = row – 1;
    refcount2 = center_row;
    refcount3 = row / 2;
    for (int i = 1; i <= row; i++)
    {
    count3 = refcount3;
    count2 = refcount2;
    count1=refcount1;
    count=refcount;

    if (i <= center_row)
    {
    for (int j = 1; j 0)
    {
    Console.Write(“&”);
    }
    else if (count1– > 0)
    {
    Console.Write(“#”);
    }
    }
    else
    {
    if (count1– > 0)
    {
    Console.Write(“#”);
    }
    else if (count– > 0)
    {
    Console.Write(“&”);
    }
    }

    }
    Console.WriteLine();
    ++refcount;
    –refcount1;
    }
    else
    {
    for (int j = 1; j 0)
    {
    Console.Write(“#”);
    }
    else if (count3– > 0)
    {
    Console.Write(“&”);
    }
    }
    else
    {
    if (count3– > 0)
    {
    Console.Write(“&”);
    }
    else if (count2– > 0)
    {
    Console.Write(“#”);
    }
    }

    }
    Console.WriteLine();
    ++refcount2;
    –refcount3;
    }

    } Console.ReadKey();
    }

    }

    Reply

Let's Discuss