Having problem with a C Program.

Hey guys,
This is my first post in this group. I'm new in programming.

I have found a problem. Can you guys help me out from this problem.

Problem:
I want to get the output something like below:
*
**
***
****
*****

And my code is:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include<stdio.h>
main ()
{
    int n, i, st;
    char star;

    printf("Enter the character:");
    scanf("%c", &star);

    printf("The time\n");
    scanf("%d",&n);

    for(i=1; i<=n;++i)
    {
        printf("%c\n",star);
        for (st=1;st<=n;st++);
        {
            printf("%c",star);
        }
    }
}


Right now, my output is coming something like this:
*
**
**
**
**
*
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include<stdio.h>
main ()
{
    int n, i, st;
    char star;

    printf("Enter the character:");
    scanf("%c", &star);

    printf("The time\n");
    scanf("%d",&n);

    for(i=0; i<n;++i)//remove =, i=0
    {
        //printf("%c\n",star);//<<< remove this
        for (st=0;st<=i;st++)//<<< remove semicolon, i instead of n st=0
        {
            printf("%c",star);
        }
        printf("\n",0);//<<< add this
    }
}
Topic archived. No new replies allowed.