Identify the errors in the following C code and fix it so the program can run.
#include
#include
int calculate(bool* genetic);
int main()
{
int i,j,g; //counters
int population=100;
bool genetic[10][7]; //population
//initializing population
for(i=0;i
{
for(j=0;j<7;j++)
{
//randomize the genetic
genetic[i][j]=rand()%2;
}
}
for(g=0;g<100;g++)
{
printf(“generation %dn”,g);
//Evaluation
int best=0;
for(i=1;i
{
if(calculate(genetic[best])
best=i;
}
//Reproduction
for(i=0;i
{
if(i!=best)
{
for(j=0;j<7;j++)
{
if(rand()%2)
genetic[i][j]=genetic[best][j];
else
genetic[i][j]=genetic[i][j];
//mutation
if(rand()%100<4)
genetic[i][j]=rand()%2;
}
}
}
printf(“best calculate %dn”,calculate(genetic[best]));
}
getchar();
return 0;
}
int calculate(bool* genetic)
{
return ( -genetic[0] + genetic[1] + genetic[2]
-genetic[3] + genetic[4] – genetic[5]
-genetic[6] );
}