Hi, I have a homework assignment that is giving me some problems. I need to make a pyramid of * with a spaces and n rows long. It should look something like this:
____*
___* *
__* * *
_* * * *
* * * * *
I have most of it but my compiler is still coming up with errors. Please help.

# include <stdio.h>
#include <stdlib.h>
int main (void)
{
    int n;
    for (int i=0; i<n; i++);
    {
        for (int j=0; j<n-1-i; j++);
            printf (" ");
    }
    {  
        for (int k=0; k<(2*(i+1));k++)
            printf ("* ");
    }
    printf ("\n");
 
    system ("PAUSE"); 
    return 0;
}
#include <stdio.h> // There should be no spaces between # and include
#include <stdlib.h>
int main (void)
{
    int n = 9; // initialize n to the value you want
    for (int i=0; i<n; i++) // deleted the semicolon
    {
        // You print spaces until n - 1 - i
        for (int j=0; j<n-1-i; j++) // deleted the semicolon
            printf (" ");
        // After printing spaces print * until n
        for (int k=n-1-i; k<n;k++)
            printf ("* ");
        printf ("\n");
    }
 
    system ("PAUSE"); // use cin.get() or something
    return 0;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.