Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can someone fix my code based on these errors? These are the errors: driver.c: In function main: driver.c:40:13: error: expected expression before / token int

Can someone fix my code based on these errors?

These are the errors:

driver.c: In function main: driver.c:40:13: error: expected expression before / token int i,x; // declare two integer variable named i and x ^ driver.c:42:4: error: ISO C90 forbids mixed declarations and code [-Wpedantic] int numpokemon; ^ driver.c:44:1: error: expected expression before / token // inserting values in array ^ driver.c:53:20: error: expected expression before / token printf(" "); // print ^ driver.c:60:57: error: invalid suffix "th" on integer constant // if you want to print the value which is greater than 4th index then this exception will be thrown by the compiler ^ driver.c:62:1: error: expected expression before / token // Exception handling ^ driver.c:42:8: warning: unused variable numpokemon [-Wunused-variable] int numpokemon; ^ driver.c:40:10: warning: unused variable x [-Wunused-variable] int i,x; // declare two integer variable named i and x ^ driver.c:40:8: warning: unused variable i [-Wunused-variable] int i,x; // declare two integer variable named i and x ^ driver.c:72:1: warning: control reaches end of non-void function [-Wreturn-type] } ^

Here is a picture to make it easier to understand

image text in transcribed

This is my code:

int main() { int i,x; // declare two integer variable named i and x struct pokemon pokemonbank[5]; int numpokemon;

// inserting values in array for(i=0;i

// printing of array printf(" "); // print for(i=0;i

// if you want to print the value which is greater than 4th index then this exception will be thrown by the compiler scanf("%d",&x); // Exception handling if(x>4) { printf("You don't have access for this index "); } else { printf("%d ",pokemonbank[x]); } return 0; }

driver.c: In function 'main': driver.c:40:13: error: expected expression before / token int i,x; // declare two integer variable named i and x driver.c:42:4: error: ISO 690 forbids mixed declarations and code [-Wpedantic] int numpokemon; driver.c:44:1: error: expected expression before ' token // inserting values in array driver.c:53:20: error: expected expression before V/' token printf(" "); // print driver.c:60:57: error: invalid suffix "th" on integer constant // if you want to print the value which is greater than 4th index then this exception will be thrown by the compiler driver.c:62:1: error: expected expression before V/' token // Exception handling driver.c:42:8: warning: unused variable 'numpokemon' [-Wunused-variable] int numpokemon; driver.c:40:10: warning: unused variable 'x' [-Wunused-variable] int i,x; // declare two integer variable named i and x driver.c:40:8: warning: unused variable 'i' [-Wunused-variable] int i,x; // declare two integer variable named i and x driver.c:72:1: warning: control reaches end of non-void function [-Wreturn-type]

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle9i Database Administrator Implementation And Administration

Authors: Carol McCullough-Dieter

1st Edition

0619159006, 978-0619159009

More Books

Students also viewed these Databases questions