Write short program that uses a for loop to populate an array
Write short program that uses a for loop to populate an array. The array can store up to 10 integers.
Modify the code slightly to create bug that would prevent the code from compiling or even better from running correctly.
Be sure to describe what the code is designed to do. Monitor the post to comment when other students work to repair your code.
Respond to one other student post by correcting their code and explaining what was corrected.
Only respond to one student so everyone will have an opportunity to fix some code.
The following code needs to be corrected and explain what was corrected:
#include <stdio.h>
int main() {
int i, fib[1];
fib[0] = 0;
fib[1] = 1;
for( i = 2; i < 10; i++ ) {
fib[i] = fib[i – 2] + fib[i – 1];
}
for( i = 0; i < 10; i++ ) {
printf( “Fibonacci[%d] = %d\n”, i, fib[i]);
}