Why this code is taking garbage values ?
I am running this code, for 7 values and it is fine (I changed it to take 7 values at that time). But when I am trying it for 10 values, it is taking garbage values. Plz help me out 🙏 #include <iostream> using namespace std; int main() { int i,j,temp; int arr[10]; cout<<"Enter the ten numbers that are to be sorted : "<<endl; for(i=0;i<10;i++) { cin>>arr[i]; } for(i=0;i<10;i++) { for(j=0;j<10-i;j++) { if(arr[j]<arr[j+1]) { temp = arr[j]; arr[j]=arr[j+1]; arr[j+1]=temp; } } } cout<<"The sorted numbers are : "<<endl; for(i=0;i<10;i++) { cout<<arr[i]<<" "; } return 0; } Plz help 🙏