Quote Originally Posted by manishfzr1995 View Post
A slight modification of your code and it is working well.Just carefully go through the program and see how it works.
Code:
#include <stdio.h>
#include <stdlib.h>
 
int main()
{
    int space, row, stars, i,number_of_stars;


    printf("How many rows you want?");
    scanf(" %d", &row);


    for (i = 1; i <= row; i++)
    {
        number_of_stars=i; 
        
        for (space = 1; space <=row-i; space++) 
            {
                         printf(" ");
                        }


        for (stars = 1; stars <= number_of_stars; stars++) 
            {
                         printf(" *");
                        }


        printf("\n");
    }
    return 0;
}
Ohh I just noticed why did you put another variable there? I could just use number_of_stars if it's equal to 'i' anyway? or if I used number_of_stars to be scanned?