I keep getting errors on my code. 8 errors and 9 warnings. Can anyone help or tell me what is wrong? Thanks in advance.
-
Line 13 - warning: implicit declaration of function displayinfo (-Winplict-function-declaration) Line 27/34 - suggest parentheses around assignment used as truth value [-Wparentheses] Line 37 - error: expected identifier or '(' before 'int' Line 58 - error: redeclaration of 'matrixA' with no linkage Line 37 - note: previous declaration of 'matrixA' was here Line 58 - error: expected identifier or '(' before 'int' Line 83 - error: 'indexI' undeclared (first use in this function) Line 83 - note: each undeclared identifier is reported only once for each function it appears in Line 83 - error: 'indexJ' undeclared (first use in this function) Line 83 - warning: left-hand operand of comma expression has no effect [-Wunused-value] Line 83 - error: 'indexK' undeclared (first use in this function) Line 83 - warning: left-hand operand of comma expression has no effect [-Wunused-value] Line 81 - warning: variable 'matrixUser' set but not used [-Wunused-but-set-variable] Line 58 - warning: unused variable 'matrixA' [-Wunused-variable] Line 101 - error: matrixUser undeclared (first use in this function) Line 101 - error: matrixAns undeclared (first use in this function) Line 115 - suggest parentheses around assignment used as truth value [-Wparentheses] Lline 140 - warning: conflicting types for 'displayinfo' [enabled by default] Line 13 - note: previous implicit declaration of 'displayinfo' was here Sorry if its kinda long. My code is as below #include <stdio.h>#include <stdlib.h>#include <time.h>#define ROW 3#define COL 3void displayInfo();int main(){ displayinfo(); char select; int choose; do{ printf("\n1. Enter the option for the type of matrix problem :"); printf("\n [A] Addition"); printf("\n [S] Subtraction"); printf("\n [M] Scalar Multiplication\n"); printf("\n2. Exit Program [E]\n"); printf("\nYour choice :"); scanf("%c",&select); if (select = 'a' || select == 'A') { printf("\n\nEnter level of difficulty [1] Level 1 - Beginner"); printf("\n [2] Level 2 - Intermediate"); printf("\n Select :"); scanf("%d",&choose); } if (choose = 1) { int matrixA[ROW][COL], int matrixB[ROW][COL], int matrixC[ROW][COL] int matrixAns[ROW][COL] { int indexI, indexJ, indexK; srand(time(NULL)); for(indexI=0; indexI < ROW; indexI++) { for (indexJ=0; indexJ < COL; indexJ++) { for (indexK=0; indexK < COL; indexK++) { int randFirst=rand()% 10; int randSec = rand()% 10; int randThird=rand()% 10; matrixA[indexI][indexJ][indexK]= randFirst; matrixB[indexI][indexJ][indexK]= randSec; matrixC[indexI][indexJ][indexK]=randThird; matrixAns[indexI][indexJ][indexK]= randFirst + randSec + randThird; } } } } int matrixA[ROW][COL], int matrixB[ROW][COL], int matrixC[ROW][COL] { int indexI, indexJ, indexK; for (indexI =0; indexI < ROW; indexI++) { for (indexJ = 0; indexJ < ROW; indexJ++) { indexK = 0; printf("| %d %d | %d |", matrixA[indexI][indexJ][indexK], matrixA[indexI][indexJ+1][indexK+1], matrixA[indexI][indexJ+1][indexK+1]); if (indexI==0) printf(" + "); else if(indexJ==0) printf(" "); printf("| %d %d | %d |", matrixB[indexI][indexJ][indexK], matrixB[indexI][indexJ+1][indexK+1]), matrixA[indexI][indexJ+1][indexK+1]; printf("\n"); else printf(" "); printf("| %d %d | %d |", matrixC[indexI][indexJ][indexK], matrixC[indexI][indexJ+1][indexK+1]), matrixC[indexI][indexJ+1][indexK+1]; printf("\n"); } } } int matrixUser[ROW][COL]; { indexI, indexJ, indexK; for (indexI=0; indexI<ROW; indexI++) { for (indexJ=0; indexJ<ROW; indexJ++) indexK=0; printf("Row %d :", indexI + 1, indexJ + 1); scanf("%d %d %d", &matrixUser[indexI][indexJ][indexK], &matrixUser[indexI][indexJ+1][indexK+1], &matrixUser[indexI][indexJ+1][indexK+1]); } } } int flag=1; for (indexI=0; indexI< ROW; indexI++) { for (indexJ=0; indexJ<COL; indexJ++) { for (indexK=0; indexK<COL; indexK++) { if (matrixUser[indexI][indexJ][indexK]!=matrixAns[indexI][indexJ][indexK]) flag =0; } } } if (flag==1) { printf("Excellent"); } else { printf("Do more exercises"); } if (select = 's' || select == 'S') { printf("\n\nEnter level of difficulty [1] Level 1 - Beginner"); printf("\n [2] Level 2 - Intermediate"); printf("\n Select :"); scanf("%d",&choose); } else { printf("\n\nEnter level of difficulty [1] Level 1 - Beginner"); printf("\n [2] Level 2 - Intermediate"); printf("\n Select :"); scanf("%d",&choose); } printf("\nDo you wish to continue? [Y/N]"); printf("\nSelect :\n"); }while(choose=='N'); system("PAUSE"); return EXIT_SUCCESS;}void displayinfo(){printf("Welcome to B123096 MATRIC CAI\n");} ~You are required to use only 3 by 3 matrices. The program prompts the user with the question and the user inputs the answer. Each round consists of 3 questions. Next, the program, checks the studentâs answer. If itâs correct display any of the following responses. What is the question? Its as below: Write a program that will help tertiary level school student to learn matrix addition, subtraction and scalar multiplication. The program should allow the user to enter the difficulty level. At a difficulty level 1, the program uses only single-digit numbers in the problem; at a difficulty level 2, numbers as large as two digits. Matrices can be added or subtracted only when they have the same size. You are only required to use only 3 by 3 matrices. The program prompts the user with the question and the user inputs the answer. Each round consists of 3 questions. Next, the program, checks the studentâs answer. If itâs correct display any of the following responses : ⢠Very good! ⢠Excellent! ⢠Nice Work! ⢠Keep up the good work! Possible answers to an incorrect answer: ⢠No. Please try again. ⢠Wrong. Try once more. ⢠Donât give up! ⢠No. Keep trying. Your program should also count the number of correct and incorrect responses by the student. If the percentage is lower than 75%, display âPlease ask your teacher for extra help.â. If the percentage is 75% or higher, display âCongratulations, you are ready to go to the next levelâ. Your program should be menu-driven and must display a main menu when run. The menu should include the following options: 1. Enter the option for the type of matrix problem [A] Addition, [S] Subtraction , [M] Scalar Multiplication 2. Exit Program [E]
-
Answer:
Your code is unreadable. You need to repost it in a readable format. What I can tell looking at joust your errors is that you have basic syntax mistakes. Each error has a line number as well as an error message. Look at that line and the error message and see if you can figure out why its saying that. In the case of "undeclared" errors, check your variables and see if (a) it is declared at all, (b) if the case is the same (it has to be) and then (c) if you are out of scope of the declaration. IF you reposted in a readable form I might give you a few more hints, but Im not going to do your homework for you, sorry.
Jeff Kesselman at Quora Visit the source
Related Q & A:
- How do I get rid of the BETA message I keep getting?Best solution by support.mozilla.org
- Why do I keep getting back email that I sent failure?Best solution by Yahoo! Answers
- Why do I keep getting an error message when I use Yahoo?Best solution by Yahoo! Answers
- Can anyone help me get the code for my stereo?Best solution by Yahoo! Answers
- Can anyone help with a code for a ford fiesta radio?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.