What is problem with my code, that it shows "stack smashing detected" Problem Statement: Given an array, we have to find the smallest element in the array.
#include<stdio.h>
int main(){
    int arr[20],i,j,c,x,num;
    scanf("%d",&num);
    for(x=0;x<num;x++){
        scanf("%d",&arr[x]);
    }
    for(i=0;i<sizeof(arr)-1;i++){
        if(arr[i]>arr[i+1]){
            c=arr[i];
            arr[i]=arr[i+1];
            arr[i+1]=c;
        }
    }
    printf("%d",*(arr+0));
    return 0;
}
 
     
    