first I'm not quite sure what your doing with a==a, b==b, etc. You don't get input, and the first if statement will always be true. You need to get the input, then use a switch statement to find out what they typed, use a default label to print an error message. Second, you do rows,columns. It goes column row, if your working on a grid. columns run up and down, while rows run right-to-left So if you do [row][column] it is reversed.
----- Original Message ----- From: loriel_musicangel To: [email protected] Sent: Tuesday, July 07, 2009 3:02 AM Subject: [c-prog] its a 2D array problem this is my program about a 2D array. It should show the output MENU with the following choices: A.INSERT B.PRINT C. SEARCH D. EXIT. it still got errors. main() { int array[10][10]={}; int rows; int cols; int i,j,search; char A,B,C={'A','B','C'}; printf("MENU\n"); printf("A. INSERT\n\nB. PRINT\n\nC. SEARCH\n\nD. EXIT\n\n");} if(A==A); {scanf("Enter the number of rows:," &rows")"; scanf("Enter the number of columns:," &cols")"; for(i=0; i<rows; i++){ for(j=0; j<cols; j++){ scanf("Enter a number," &array[rows][cols]")"; }} } else if(B==B); { for(i=0; i<rows; i++){ for(j=0; j<cols; j++) printf("%d\t,"array[rows][cols]); }} else if(C==C); {scanf("Enter the number you want to find:," &search")"; for(i=0; i<rows; i++){ for(j=0; j<cols; j++){ if(search==array[rows][cols]);{ printf("The element %d is on (%d,%d),"search, rows, cols);} else {printf("The element is not found."); }}} } else{}; return 0; } [Non-text portions of this message have been removed]
