Pivot of rotated and sorted

#include
using namespace std;

int main() {

int n;
cin>>n;
int arr[n]; 
for(int i=0;i<n;i++)
{
	cin>>arr[i];
}

int s=0;
int end=n-1;

if(s>end)
{
	cout<<0;
}

while(s<=end)
{
	int mid=(s+end)/2;
	if(s>mid && arr[mid]<arr[mid-1])
	{
		cout<<mid-1<<" ";
		break;
	}
	if(mid<end && arr[mid]>arr[mid+1])
	{
		cout<<mid<<" ";
		break;
	}

	if(arr[s]>arr[mid])
	{
		end=mid-1;
	}
	else{
		s=end+1;
	}
	}

		return 0;

}

@arsh_goyal I corrected your binary_search code. Please take a look https://ide.codingblocks.com/s/187473

@arsh_goyal If you don’t have any further queries please mark the doubt as resolved.

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.