Que: Write a C program to display the following different Patterns.
A
B C
D E F
Code:
#include <stdio.h>
int main()
{
int i, j;
char alphabet='A';
for(i=1;i<=3;i++)
{
for(j=1;j<=i;j++)
{
printf("%c ",alphabet);
alphabet++;
}
printf(" ");
printf(" \n");
}
return 0;
}
A
B C
D E F
Code:
#include <stdio.h>
int main()
{
int i, j;
char alphabet='A';
for(i=1;i<=3;i++)
{
for(j=1;j<=i;j++)
{
printf("%c ",alphabet);
alphabet++;
}
printf(" ");
printf(" \n");
}
return 0;
}
No comments:
Post a Comment