my code is giving correct o/p but also showing runtime error i am not able to understand what is happening??
Rotate a string by k elements
Here runtime error is mostly because of array index out of bounds. It means that you are trying access the array element at a position greater than the defined size. I can see that in your code as in line 11. Your array size is 6 but you are trying to access elements beyond its last index.
So change line 25 to char a[100] = “tushar”; and you will not get the runtime error.
1 Like