this code get 5 numbers and find bigger number
it works correctly but when i insert 5th number,it doesnt work correctly,it just compared entered numbers:1,2,3,4
i've changed to this and it works very well
in line 25 i added 1 to num[j] like this num[j+1]
can you tell me why j+1?
i just added 1 to j
i dont know reason
#include<iostream>
#include<algorithm> //sort function library
int arr[5];
for (int i = 0; i<5; i++){
cin>>arr[i];
}
sort(arr, arr+5); //sorts array arr from smaller to bigger
cout<<arr[4]; //outputs final element, biggest since the array was sorted
return 0;
}