Here, let me put code tags around that, and indent it...
Code:
#include<stdio.h>
#include<conio.h>
void main(){
int a[10][10],i,j,k,b,l,ans;
clrscr();
for(i=1;i<10;i++){
for(j=1;j<10;j++){
printf("a(%d,%d)\t",i,j);
}
printf("\n\n\n");
}
for(i=1;i<10;i++){ //input from user
for(j=1;j<10;j++){
printf(" a[%d,%d]?\n",i,j); // i hav used 0 to represent a blank box
scanf("%d",&a[i][j]);
}
}
for(i=1;i<10;i++){
for(j=1;j<10;j++){
b=0;
if(a[i][j]==0){ //checks whether box is empty
end:
ans=0;
b=b+1; //gives a value to empty box
for(k=1;k<10;k++){
if(a[i][k]==b||a[k][j]==b){ //checks whether that value is already occupied in the same row and column
ans=1;
}
}
for(k=1;k<4;k++){
for(l=1;l<4;l++){
if(a[3*(i/3)+l][3*(j/3)+k]==b){ //checks whether that value is occupied by the bigger box containing nine boxes
ans=1;
}
}
}
if(ans=1){
goto end; //if yes, than it goes back and assign a higher value to the box
}
a[i][j]=b;
}
}
}
for(i=1;i<10;i++){ //prints the result
for(j=1;j<10;j++){
printf("%d\t",a[i][j]);
}
printf("\n");
}
getch();
}
I'll take a look, and post again.