Pages

Monday, 15 June 2015

Alphabet pattern 5

Alphabet pattern 5

Coding:

#include<stdio.h>
int main()
{
int i,j,n;
printf("Please enter number of lines:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
{
printf("%c",65+(j-1)%2);
}
printf("\n");
}
return 0;
}

Output:
Please enter number of lines:5
A
AB
ABA
ABAB
ABABA