Whats wrong with my code?

#include
#include
using namespace std;

int main()
{
cout << "Enter the size of the array: ";
int n, arr[] = { 0 };
cin >> n;
cout << "Enter the elements of the array: ";
for (int i = 0; i < n; i++) {
cin >> arr[i];
}
sort(arr, arr + n);
for (int i = 0; i < n; i++) {
cout << arr[i];
}
return 0;
}

arr[] = { 0 };
this statement will create an array of size 1
so when you try to access arr[2] or more using arr[i] then it will give error

correct way is to also give size of array

int arr[1000];


[/quote]

bhaiyaa thnx but thnx got it but still unable to get why my output is coming like 00255

You have to declare array like this
Int arr[1000]

this is a public platform do not give your number here

i will share a link of meet join it

ok pls
give the link

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.