Pattern Printing – String Characters

                   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.
Output Format:
L lines containing the desired pattern.
Boundary Condition:
2 <= L <= 100
Example Input/Output 1:
Input:
ABCD
Ouput:
A
BB
CCC
DDDD
Example Input/Output 2:
Input:
EAGLE
Ouput:
E
AA
GGG
LLLL
EEEEE
Code:
#include <iostream>
#include<string.h>
using namespace std;
int main(int argc, char** argv)
{
char str[100];
int i,j,k=0;
cin>>str;
for(i=1;i<=strlen(str);i++)
    {
        for(j=0;j<i;j++)
            {
                cout<<str[k];
            }
        k++;
        cout<<"n";
    }}

Please do comment If u have any Queries!

One Comment

Add a Comment

Your email address will not be published. Required fields are marked *