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<stdio.h>
#include<string.h>
int main()
{
    char s[20];
    int i, j;

    printf("Enter the string: ");
    //scanf("%s", s);
    gets(s);

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





"Coding Hub - Learn to code" app now available on Google Play Store