Hey guys,
I was studying for my test and I came across a question that left me baffled. I am supposed to find and fix the bugs in the code below. I was able to find 2 bugs and I was hoping one of you could help me find the rest, if there are any more.

The following program creates a linked list of nodes with random numbers between 1-100 as the data values. It then traverses and outputs the data values 8 per line. At the end of the program the for loop is supposed to delete all the nodes and release the dynamic memory space that they occupy.

Here is the code(with err0rs):

insert
Code:
#include <stdio.h>
#include <stdlib.h>
int main ()
{
struct node /* a linked list node type */
{ int data;
struct node *next;
};
struct node *first = NULL, *temp;
int i, n, k, count;
k = rand( ) % 1000 + 1;
/* create the linked list of k nodes with random values between 1-100 */
for (i = 1, i <= k; i++);
{
n = rand( ) % 100 + 1;
temp = malloc(sizeof(struct node));
temp -> data = n;
temp -> next = first;
first = temp;
}
/* traverse the linked list and output the node data values, 8 per line */
count = 0;
for (temp = first; temp != NULL; temp = temp -> next)
{ count++;
printf ( “%d ”, temp->data) ;
if (count = 8) {printf (“\n”); count = 1;}
}
/* traverse and release the memory for the nodes of the linked list */
for (temp = first; temp != NULL; temp = temp -> next)
{
free (temp);
}
return 0;
}
the errors I have found so far are that the if(count=8) should actually be if(count==8) and in the same line count=1 should be count=0 since count should start at 0, not 1.
Could you please help me find the rest of the bugs?
Please hurry, my test is tommorow morning!!
Thanks