Hi, I'm supposed to make a program that asks the user how many integers they want to input, then prompt them to enter those integers. and then I'm supposed to put those integer into ascending order. How do I do that?

this is my code so far

#include <iostream.h>

void main (void)
{
	int *array, num;

	cout << "How many integers do you wish to allocate?";
	cin >> num;

	array = new int[num+1];
	if (array == NULL)		
	{						
		cout << "Error allocating memory!\n";
		return;
	}

	cout << "Enter the integers here: \n"; 
	for (int count =0; count < num; count++)
	{
		cout << "Integer # " << (count +1) << ": ";
		cin >> array[count];
	}

You should use #include <iostream>, not #include <iostream.h>.

You should use int main(), not void main(void).

Judging by your style of code, it seems that for whatever reason, you're not using the standard library. (You could use the std::sort function.) In that case, you'll want to write a subroutine that, when given a pointer to an array of integers and the length of the array, rearranges the elements in ascending order.

How would you do that, you say? Well, how would you put a deck of cards in ascending order? There are many ways.

I'm sure you'll soon get some people posting their own functions or giving code for using the already-existing std::sort function (which you could just look up anyway), but since you seem to be learning, it's much better to figure it out yourself.

I already gave you a hint: how would you go about systematically sorting a deck of cards?

Though it's not a thing to learn by cut-n-pasting other's source code, it's not a thing to re-invent yourself either (mainly if you're a beginner).

Look here for a really simple tutorial about sorting, with source code. Save the site for future reference. It has a lot of content for you.

di ko din alam pano mag ascending order din.. hahaha

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.