Getting 1 run timer error and 1 wrong answer

Arrays-Wave print Column Wise is the problem and my code seems to work fine for all the possible cases that i could test.

Hello @S19LPPP0159 Gautam,
Your logic is fine but since you are declaring an m*n array, the indexing is done from 0 to n-1 and 0 to m-1 and not from 1.
So, you need to change every loop accordingly and the conditions for odd and even column as well.
Also, your code is giving garbage values for some cases like for 2 rows and 6 columns.
Hit like if you understood.

@D18LP0082 Thanks for looking into my problem.
Actually I intialized array from 1 to n in first for loop,hence no garbage value was introduced,
also for m=2 n=6 i didnt saw any garbage values.
i attached a screenshot

@S19LPPP0159 Look at this screenshot, it is giving random values for this set of values.
Although, your program is giving correct output for some cases, it may produce random values in others due to the indexing.

1 Like

@D18LP0082 Could You modify the code, to remove these errors ??

@S19LPPP0159 Here is the updated code: https://ide.codingblocks.com/s/92369 .
It required only minor changes.
I suggest you go through it once to see the changes I have made and then submit it.
Please mark the doubt as resolved if you understand it.
Also, do give a rating on the basis of your experience. The rating option is available where you mark your doubt as resolved

1 Like