# Thread: !value required as left operand of assignment

1. ## !value required as left operand of assignment

Its the problem with my loop part. How do I fix this?
Code:
```#include <stdio.h>

/* Define constant NUM_FIBON (number of fibonacci numbers) to be, say, 12 */
#define NUM_FIBON 12
int main()
{
/* Declare and initialise an int array with the first 2 fibonacci numbers 1 and 1 */
/* The size of the array should be NUM_FIBON. */
int fibonacci[NUM_FIBON] = {1, 1};

/* Display the purpose of the program */
printf("\nThis program displays the first %d fibonacci numbers\n", NUM_FIBON);

/* Populate the array with other fibonacci numbers, starting with the 3rd number */
/* Each fibonacci number is the sum of the previous two */
for (NUM_FIBON = 2; NUM_FIBON<=12; NUM_FIBON++)
{
fibonacci[NUM_FIBON] = fibonacci[NUM_FIBON-1] + fibonacci[NUM_FIBON-2];
}``` 2. Hint: a #define resolves to plain text substitution (eg: after the preprocessor has passed through the code, the macro is replaced by whatever you defined it as (also known as macro expansion)). In other words:

Code:
```#define STUFF char* p

int main( void )
{
STUFF;
STUFF;
}

// after expansion:

int main( void )
{
char* p;
char* p; // error: redeclaration of 'p'
}```
hth. 3. Your code, after the preprocessor has run:
Code:
```#include <stdio.h>

/* Define constant NUM_FIBON (number of fibonacci numbers) to be, say, 12 */
int main()
{
/* Declare and initialise an int array with the first 2 fibonacci numbers 1 and 1 */
/* The size of the array should be NUM_FIBON. */
int fibonacci = {1, 1};

/* Display the purpose of the program */
printf("\nThis program displays the first %d fibonacci numbers\n", 12);

/* Populate the array with other fibonacci numbers, starting with the 3rd number */
/* Each fibonacci number is the sum of the previous two */
for (12 = 2; 12<=12; 12++)
{
fibonacci = fibonacci[12-1] + fibonacci[12-2];
}```
I don't know about you, but some parts of the code doesn't make sense to me. 4. thkx 4 ur help Elysia 5. Note also that after you correctly use a local variable as the loop counter, your loop should have < NUM_FIBON as the ending condition, not <= NUM_FIBON or you'll have a buffer overrun. Array indexes go from 0 to N-1 Popular pages Recent additions 