Last Updated :
10 Apr, 2024
Given below is a code snippet of sorting an array. Predict the output for the below part of the program:
int arr[] = {2, 10, 5, 3, 4, 9, 8};
sort(arr + 2, arr + sizeof(arr)/sizeof(arr[0]));
for(int i = 0; i < sizeof(arr)/sizeof(arr[0]); i++)
cout << arr[i] << \" \";
(A) 2 10 5 3 4 8 9
(B) 2 3 4 5 8 9 10
(C) 2 10 3 4 5 8 9
(D) None of the mentioned
Answer: (C)
Explanation:
sort(start, end): arranges the element from start to end in ascending order.
Share your thoughts in the comments
Please Login to comment...