What would be the solution for this even though i already declared i as an int in the for loop?
#include <stdio.h>
#include <cs50.h>
int main(void)
{
int length;
do
{
length = get_int("Length: ");
}
while (length < 1);
int twice[length];
for (int p = 0; p < length; p++);
{
twice[p] = 2 * twice[p - 1];
printf("%i\n", twice[p]);
}
}
You have an extra
;
before the for loop body.OT: When the
;
problem is fixed, what is the value ofp
intwice[p - 1]
on the first iteration?