Here's a program to sort N numbers in ascending order using a function template:
In this program, we first declare a function 'sort_array' that takes an array of any datatype 'T' and its size 'n'. This function sorts the array using a simple bubble sort algorithm.
Then in the 'main' function, we ask the user for the number of elements and the integers to be stored. And we declare an array of the integers and fill it with the user's input. We then call the 'sort_array' function with the array and its size, and print the sorted array.
No comments:
Post a Comment
If you have any doubts, please let me know