Runtime error in rotation of string by k

#include
#include
using namespace std;

void rotate(char *a,int k){
int i = strlen(a);
while(i>=0){
a[i+k] = a[i];
i–;
}
i = strlen(a);
int y = i-k;
int s = 0;
while(k<i){
a[s] = a[y];
s++;
y++;
}
a[i-k] = ‘\0’;

}
int main() {
char a[100] = “yellow”;
int k=2;

rotate(a,k);
cout<<a<<endl;

}

it is showing runtime error in rotation of string by k

@LPLC0006
Condition for second while loop is while (k < i)
Neither k is incremented nor i is decremented. This loop will run infinitely as its condition remains true always and thus your code gives a runtime error.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.