Pattern Printing - String Characters
Given a string S of length L, the program must print the pattern as described in the Example Input/Output.
Input Format:
First line contains the string S.
First line contains the string S.
Output Format:
L lines containing the desired pattern.
L lines containing the desired pattern.
Boundary Condition:
2 <= L <= 100
2 <= L <= 100
Example Input/Output 1:
Input:
ABCD
Input:
ABCD
Ouput:
A
BB
CCC
DDDD
A
BB
CCC
DDDD
Example Input/Output 2:
Input:
EAGLE
Input:
EAGLE
Ouput:
E
AA
GGG
LLLL
EEEEE
E
AA
GGG
LLLL
EEEEE
C program:
#include<stdio.h>
#include <stdlib.h>
int main()
{
char a[100],ch;
int i=0;
while((ch=getchar())!='\n')
a[i++]=ch;
a[i]='\0';
i=0;
while(a[i]!='\0')
{
for(int j=0;j<=i;j++)
printf("%c",a[i]);
i++;
printf("\n");
}
}
No comments:
Post a Comment