Code Snippets

Pyramid Star Printing

                                    
    #include <stdio.h>

        int main()
        {
            int lines = 5;
        
            printf("Enter the number of lines for pyramid: ");
            scanf("%d", &lines);
            printf("\n");
        
            int space = lines;
            int stars = 1;
        
            for (int i = 1; i < lines + 1; i++)
            {
                for (int j = 1; j < space; j++)
                {
                    printf(" ");
                }
        
                for (int k = 0; k < stars; k++)
                {
                    printf("*");
                }
        
                stars = stars + 2;
                space--;
                printf("\n");
            }
        
            printf("\nSee you soon, have a nice day :)");
        
            return 0;
        }