There are multiple problems. Some of them should be already indicated by the compiler.
See the comments:
int main()
{
int a[100],n,i;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
printf("%d",a[n]);
check(int n,int a[]);
if (check(int n,int a[]) = 1)
{
printf("the array isn't sorted");
}
return 0;
}
int check(int n,int a[])
{
int i,s;
for(i=0;i<n;i++)
{
if(a[i] < a[i+1])
{
s = a[i];
a[i] = a[i+1];
a[i+1] = s;
return 0;
}
else {
return 1;
}
}
}
The requirement is to check if the array is sorted but the above code will modify one element and return zero when
any element is less than the next. From my point of view the array should not be modified. Also I would think of being sorted means that
all elements are in ascending order. So the condition to leave the loop and return "not sorted" would be when any element is larger than the next (or smaller than the previous).