#include <cs50.h>
#include <stdio.h>

int main(void)
    int n, i;
        printf("Heigh: ");
        n = get_int();
    }while(n<0 || n>23);

    for (i=1; i<=n; i++)
        for(int e=1, e<n-i, e++)
            printf(" ");
        for(int h=1, h<2+i, h++)

^this is the code i wrote

this is the errors i get


Your for statements have expressions separated by commas instead of semi-colons:

for(int e=1, e<n-i, e++)

should be:

for(int e=1; e<n-i; e++)

You can have comma-separated expressions in more complex for-loops (or even skip an expression), but you still need two semi-colons inside the parenthesees.

For instance,

for (int a = 1, b = 10; a <= b; a++) {
    printf("a=%d b=%d\n", a, b);

initializes TWO variables before the first semi-colon, has a conditional expression between the two semi-colons and an increment step after the last semi-colon.

| improve this answer | |
  • thank you so much for the answer! it's working now. – Pexan Aug 23 '17 at 10:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .