- Joined
- Nov 29, 2019
- Messages
- 2
- Reaction score
- 0
Hello. Could anyone tell me why does the code below not run properly? I intended to print a pyramid using * but the output is strange.
For example, if I run this code and give "rows" a value of 5 it outputs 11 stars one after each other. Help me, please.
C:
#include <stdio.h>
int main ( )
{
int i , j , rows ;
printf("Enter the number of rows:");
scanf("%d", &rows);
for ( i = 1 ; i <= rows ; i++);
{
for ( j = 1 ; j <= rows - i ; j++)
printf(" ");
for ( j = 1 ; j <= 2 *i - 1 ; j++)
printf("* ");
printf("\n");
}
}
For example, if I run this code and give "rows" a value of 5 it outputs 11 stars one after each other. Help me, please.