Sunday, January 1, 2012

Print following pattern. A BB CCC DDDD in 'C'


A
BB
CCC
DDDD

Example



#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,n;
char c;
clrscr();
printf("Enter the value of n:");
scanf("%d",&n);
c=65;
for(i=0;i<=n;i++)
{
for(j=0;j<=i;j++)
{
printf("%c",c);


}
     c++;
printf("\n\n");
}
getch();
}
/*=====================================================================
OUTPUT
Enter the value of n:4
A
BB
CCC
DDDD



5 comments:

  1. Both loop must start with the initial value 1 , or just remove = sign from the outer loop .

    ReplyDelete
    Replies
    1. here 0 will count as firts position (it just a position)

      Delete
  2. Replies
    1. This comment has been removed by the author.

      Delete