Logo 
Search:

C Programming Articles

Submit Article
Home » Articles » C Programming » Homework HelpRSS Feeds

Program to print pyramid of small letter and capital letter abcd

Posted By: Freya Brown     Category: C Programming     Views: 17038

WRITE A PROGRAM TO GENERATE FOLLOWING FIGURE OF N LINES.
INPUT N FROM KEYBOARD. Consider space in place of line.
_____a
____a A
___a A b
__a A b B
_a A b B c

Code for Program to print pyramid of small letter and capital letter abcd in C Programming

#include<stdio.h>
#include<conio.h>
void main()
{
        int i,n,j;
        char c,ch;
        clrscr();
        printf("\n Please Give The Value of N:  ");
        scanf("%d",&n);
        if(n>20)
        {
            printf("\n N MUST BE LESS THAN OR EQUAL TO 20 ");
            printf("\n OTHERWISE IT IS NOT DISPLAY AS PYRAMID");
            printf(" OR NOT FIT IN ");
        }
        else
        {
        for(i=1;i<=n;i++)
        {
            for(j=1;j<=n-i;j++)
            printf("  ");
            for(j=1,c=97,ch=64;j<=i;j++,c++,ch++)
            {
                if(j%2==1)
                {
                    printf(" %c  ",c);
                    c=c-1;
                }
                else
                {
                    printf(" %c  ",ch);
                    ch=ch-1;
                }
            }
            printf("\n");

        }
    }
    getch();
}



********************** OUTPUT *************************************



     Please Give The Value of N:  7


                 a
               a   A
             a   A   b
           a   A   b   B
         a   A   b   B   c
       a   A   b   B   c   C
     a   A   b   B   c   C   d




*********************************************************************[/Code]
  
Share: 



Freya Brown
Freya Brown author of Program to print pyramid of small letter and capital letter abcd is from London, United Kingdom.
 
View All Articles

Related Articles and Code:


 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
Ron Moreland from United States Comment on: Jun 13
How would a beginner like me work on a code such as this?
Display a square and a rectangle using asterisks. That I can enter two different integers, both odd numbers. Validate that the two numbers are in the range of 3 to 15 , and that they are both odd numbers, i.e., not even numbers.

View All Comments