0
Can you kindly explain this code?
I was trying to make this code for a long time and.. I made it.. but I don't understand one thing.. Variable x is unused.. so if I remove this, code acts differently.. https://code.sololearn.com/cUJAx5fUpft0/?ref=app
1 Respuesta
+ 1
HeyMohammad Mehedi Hasan
1.you doesn't use the value of x , so gives warning
2. how you are accessed array[3]'s value it is undefined
This will help you 👇
#include <iostream>
using namespace std;
int main() {
int arr[3] = {1,2,3};
int x;
for (int i=0; i<3; i++) {
x = arr[0];
for (int j=0; j<3; j++) {
if(j==2)
arr[j]=x;
else
{arr[j] = arr[j+1];}
cout<<arr[j];
}
}
return 0;
}