C++ Program to Display User Provided String Pyramid

In this program, you'll learn to print pyramid of string given by user.



Source Code
#include<iostream>
#include<string.h>
using namespace std;

int main()
{
    char s[20];
    int i, j;

    cout<<"Enter the string: ";
    gets(s);

    for(i=0; i<strlen(s); i++)
    {
        for(j=0;j<=i; j++)
        {
            cout<< s[j];
        }
        cout<<"\n";
    }
    return 0;
}
Output
Enter the string: Tavera
T
Ta
Tav
Tave
Taver
Tavera