Simple C Program to Print Alphabet Pattern using For Loop

 
Using this program user can print following pattern 


                                                                   A
                                                            B           B
                                                       C        C         C
                                                  D       D         D       D

Program:

 //C Program to print Pattern by www.SlashMyCode.com
#include<stdio.h>
#include<conio.h>
void main()
{
    int i,j;
    for(i=0;i<=3;i++)
    {
        for(j=i;j<=3;j++)
    {
        printf("\t");
    }
    for(j=0;j<=i;j++)
    {
        printf("\t%c\t",'A'+i);
    }
    printf("\n");
    }
    getch();
}

 Output:
Output of Alphabet Pattern using For Loop






 
  This is the output you will  get if you run the above program

Algorithm: 

  1. Start
  2. define i,j
  3. i=0 if i<=3,i++ if  YES then go to STEP 4 if NO then go to STEP 9
  4. j=1 if j<=3,j++ if YES than go to STEP 5 if NO then go to STEP 6 
  5. print space and go to STEP 4
  6. j=0 if j<=i,i++ if YES go to STEP 7 if NO than go to STEP 8
  7. print space char space then go to STEP 6
  8. print new line(\n) then go to STEP 3
  9. Stop 


No comments:

Post a Comment

Feel free to ask us any question regarding this post