i've done this code to print a triangle after a side is scanned. It does show me the triangle but it prints me a new line right after i add a side which is not meant to be there. Here is my code and i'll also add my output, i've marked the new line with white. Please help, thank you.
#include<stdio.h>
void printTriangle (int n)
{
for (int i = 0; i <= n; i++)
{
for (int j = 0; j < i; j++)
{
if (j > 0 && j < (i-1) && i > 0 && i < n)
{
printf("-");
}
else
{
printf("*");
}
}
printf ("\n");
}
}
int main ()
{
int n;
scanf ("%d", &n);
printTriangle (n);
return 0;
}