Write a clear and concise C program that implements a bubble sort algorithm to sort an array of integers in ascending order. Your program should prompt the user to enter the array size and values, then display the sorted array. It should also include proper error handling and comments to improve code readability. To make your program more efficient, consider optimizing your algorithm by stopping the sort once no more swaps are needed.
This prompt doesn't seem malicious.