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