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

So I've been playing around with this problem alot and unforturnatly asked many questions. But I think I've figured out the basics, if not back to the drawing board.  My question is this I've been trying to create an array 

    num[i]+=1
or is it

    num[i] = i + 1

however no matter where I put it or if I add a precursor to the num[i], I always get an error.  Even if I'm wrong on the math I just want to know how you use arrays with for loops.  I've looked around online and tried to figure it out but nothing is working.

Oh and num was my int input question.




    // add spaces and rows
        for (int i = 1 ; i <= num; i++)
        {

            printf (" ",(num[i]+=1));


        // add hashtags and columns
            for (int n = 0; n <= num; n++)

                printf ("#");
                printf ("\n");



        }


    }
0

I honestly do not understand what your question is, but the statement is incorrect:

printf (" ",(num[i]+=1));

In printf, what goes after the quotes is variable that will be printed, with the appropriate support, that is, if we want to print an integer variable, we write:

printf("%d", variable_name);

If you want to print a space simply print it:

printf(" ");
2
  • I do want to print the printf (" "); however for each row I want to increment the space each row by 1. I thought an array would be proper. Ideas?
    – MikaLand
    Sep 19 '18 at 23:07
  • I got the program to work, without an array. Still not sure how to use arrays though, I'll look it up some more. Thanks for your help!
    – MikaLand
    Sep 20 '18 at 0:28

You must log in to answer this question.

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