C/C++ Program to Read Infinite Numbers and Arrange Them in Ascending Order

In this program we are reading infinite numbers and then arranging them in ascending order. Here infinite means, the program should read numbers until a particular number is entered to terminate the reading process. In our case we are using -1 to stop the reading process. As we already don’t know how many numbers will be entered by the user so we are using concept of dynamic memory allocation to allocate memory for a number at the run time. I have used indexing with pointer to make the program more readable and easy to understand. You can comment below if you find any difficulty in understanding the program.

C Program

C++ Program

Output
C/C++ Program to Read Infinite Numbers and Arrange Them in Ascending Order

3 thoughts on “C/C++ Program to Read Infinite Numbers and Arrange Them in Ascending Order”

Leave a Comment

Your email address will not be published. Required fields are marked *