0

Why is my code not working

Array practice https://code.sololearn.com/cO91iJpoqVDp/?ref=app

13th Nov 2018, 7:27 PM
Josiah Mitchell
Josiah Mitchell - avatar
7 Answers
+ 6
Line 4: int arr[7] = {7,1,14,11,6,21,32}; Line 10: if (arr[i] > large) Line 15: printf ("large: %d\n", large );
13th Nov 2018, 7:44 PM
Ipang
+ 5
There are a few syntax and logic errors in your code... Syntax - At line 4 when initialising the array you put the [7] on the wrong side of the assignment (=), should be after the array name - At line 15 when you print out the largest number you forgot a semi-colon (;) - On the same line you tried to put a new line but put in the wrong slash should be \n not /n Logic - When checking if the array element is larger than the previous largest number you put in a less than symbol (<) which will give you the opposite effect change that to greater than (>) I made the changes here among other non-essential ones: https://code.sololearn.com/c5WxXN8HAQ0W/?ref=app
13th Nov 2018, 7:40 PM
TurtleShell
TurtleShell - avatar
+ 4
Because you declare in bad way an array and you forget a semicolon after printf call
13th Nov 2018, 7:36 PM
KrOW
KrOW - avatar
+ 3
TurtleShell Roneel Ipang KrOW thanks for the help. I'm pretty new to c programming and I'm trying to not just make functional code, but also learn the logic as well. Thanks again 😁
13th Nov 2018, 7:47 PM
Josiah Mitchell
Josiah Mitchell - avatar
+ 1
TurtleShell still you forgot large - largest in line 15
13th Nov 2018, 7:41 PM
Roneel
Roneel - avatar
+ 1
Roneel ohh didn’t see that, thank you
13th Nov 2018, 7:43 PM
TurtleShell
TurtleShell - avatar
0
What way is best ? I'm new to c programming.
13th Nov 2018, 7:39 PM
Josiah Mitchell
Josiah Mitchell - avatar