Is there a shorter way of interpreting my code (solved) | Sololearn: Learn to code for FREE!


Is there a shorter way of interpreting my code (solved)


4/14/2021 6:42:09 AM


1 Answer

New Answer


Yes, definitely. First, fix all the bugs in your code, though. After you fix everything below and test that it works, I'll help you shorten it. It is more difficult to refactor code that is buggy or can't compile. Shortening it risks wasting my time more when you make the task so big with both a long list of bug fixes. For all I know, I'll spend lots of time fixing everything and shorten it and then you'll just go with someone else's answer anyway. Here are some fixes: - Replace scanf("%s", &name); with scanf("%s", name); - Replace correct[4]++; with correct[3]++; The array is 0-based so the valid index range is 0..3 inclusive. 4 risks a memory access violation or segmentation fault because that's not part of the array[4] you declared. - Decrement all your other correct array indexes by 1 so they fit in a valid range. - In a similar way, decrement your array indexes for grade. - In multiplication(), fix printf format for grade. It should be %6.2f instead of %d. - In division(), answer this question. what is this supposed to mean? while(a<b, a%b!=0); Do you want an or(||) operator or an and operator(&&)? - consider removing conio.h and replacing getch with getchar. getch is from Turbo c++ and is not part of the standard libraries for c.