in this program countg is not being incremented and count is not being displayedCode:// final.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <conio.h>
#include <ctype.h>
using namespace std;
int call_boxi(int a[8][8],int box){
if(box>=1&&box<=8){
int i=0;
return i;}
if(box>=9&&box<=16){
int i=1;
return i;}
if(box>=17&&box<=24){
int i=2;
return i;
}
if(box>=25&&box<=32){
int i=3;
return i;
}
if(box>=33&&box<=40){
int i=4;
return i;
}
if(box>=41&&box<=48){
int i=5;
return i;
}
if(box>49&&box<=56){
int i=6;
return i;
}
if(box>=57&&box<=64){
int i=7;
return i;
}
}
int call_boxj(int l[8][8],int box){
if(box>=1&&box<=8){
int j=box-1;
return j;}
if(box>=9&&box<=16){
int j=box-9;
return j;}
if(box>=17&&box<=24){
int j=box-17;
return j;
}
if(box>=25&&box<=32){
int j=box-25;
return j;
}
if(box>=33&&box<=40){
int j=box-33;
return j;
}
if(box>=41&&box<=48){
int j=box-41;
return j;
}
if(box>49&&box<=56){
int j=box-49;
return j;
}
if(box>=57&&box<=64){
int j=box-57;
return j;
}
}
int call_boxy(int l[8][8],int box){
if(box>=1&&box<=8){
int j=box-1;
return j;}
if(box>=9&&box<=16){
int y=box-9;
return y;}
if(box>=17&&box<=24){
int y=box-17;
return y;
}
if(box>=25&&box<=32){
int y=box-25;
return y;
}
if(box>=33&&box<=40){
int y=box-33;
return y;
}
if(box>=41&&box<=48){
int y=box-41;
return y;
}
if(box>49&&box<=56){
int y=box-49;
return y;
}
if(box>=57&&box<=64){
int y=box-57;
return y;
}
}
int call_boxx(int a[8][8],int box){
if(box>=1&&box<=8){
int x=0;
return x;}
if(box>=9&&box<=16){
int x=1;
return x;}
if(box>=17&&box<=24){
int x=2;
return x;
}
if(box>=25&&box<=32){
int x=3;
return x;
}
if(box>=33&&box<=40){
int x=4;
return x;
}
if(box>=41&&box<=48){
int x=5;
return x;
}
if(box>49&&box<=56){
int x=6;
return x;
}
if(box>=57&&box<=64){
int x=7;
return x;
}
}
int check_and_copy(int a[8][8],int l[8][8], int final[8][8]){
cout<<"enter the number of each square by pressing enter after each square number"<<endl;
int box1;
int box2;
int count=0;
int countg=0;
while(count<32){
cin>>box1;
cin>>box2;
int i=0;
if(box1>=1&&box1<=64&&box2>=1&&box2<=64){
int i=call_boxi(a,box1);
int j=call_boxj(a,box2);
int x=call_boxx(a,box1);
int y=call_boxy(a,box2);
if(a[i][j]==a[x][y]){
if(a[i][j]!=final[i][j]){
final[i][j]=a[i][j];
final[x][y]=a[x][y];
count++;
cout<<"your answer is right enter another one"<<endl;}}
else{if(a[i][j]==final[i][j]||a[x][y]==final[x][y]){
cout<<"you already gave this answer"<<endl;}}
else{ if(a[i][j]!=a[x][y]){
cout<<"your answer is wrong try again"<<endl;}}}
else{ cout<<"your answer is out of bound try again"<<endl;}
countg++;
for(int i=0;i<8;i++){
for(int j=0;j<8;j++){
cout<<l[i][j]<<" ";}cout<<endl;}
cout<<"# of right answers is"<<count<<endl;
cout<<"# of total gusses is "<<countg<<endl;}
return final[8][8];}
void assign_half(int a[8][8],int r, int c){
for(int i=0;i<4;i++){
for(int j=0;j<8;j++){
a[i][j]=rand()%100;
}
}
}
void double_of_each(int a[8][8],int r,int c){
int maxr=4;
for(int i=0;i<4;i++){
int maxc=7;
for(int j=0;j<8;j++){
a[maxr][maxc]=a[i][j];
maxc--;
}
maxr++;}
}
int assignl(int l[8][8],int r,int c){
int f=1;
for(int b=0;b<8;b++){
for(int c=0;c<8;c++){
l[b][c]=f;
f++;
}}
return l[8][8];
}
void disp(int l[8][8],int r,int c){
for(int i=0;i<r;i++){
for(int j=0;j<c;j++){
cout<<l[i][j]<<" ";
}
cout<<endl;
}
}
int _tmain(int argc, _TCHAR* argv[])
{
int a[8][8]={0};
int f[8][8]={0};
int l[8][8]={0};
int r=8;
int c=8;
assignl(l,r,c);
disp(l,r,c);
assign_half(a,r,c);
double_of_each(a,r,c);
check_and_copy(a,l,f);
getch();
return 0;
}
and also the last else in the check_and_copy function is not matched to the first if how can i solve it