Start New Discussion within our Software Development Community

I need to sort a series of 25 numbers, entered by the user from smallest to largest, then count the number of times the user entered the number "10". I can't use arrays and I have to use only for loops, can someone please help?

When you say you "can't use arrays", what exactly does that mean? Because it's quite impossible to sort anything when you can't retain it, and while you can use 25 variables to get the same effect as an array, that's totally insane. I can't imagine a teacher expecting you to do that unless they subscribe to the school of hard knocks and want to teach you the importance of arrays.

well I can't use an array set up like "array[45]" the user just needs to enter 25 integers and the program needs to sort it and print the number of times the number "10" is printed.

never mind, i overestimated it.

#include <iostream>
using namespace std;

int main()
	int max;
	int min;
	int ten=0;
	int total;
	int i;
	cout << "Please Enter a number" << endl;
	cin >> max;


	if (max==10)
	for (int x=1; x<25; x++)
		cout << "Please Enter a number" << endl;
		cin >> i;

		if (i>max)
		if (i<min)
		if (i==10)
		total += i;
	cout << "Max =  " << max << endl << "Min =  " << min << endl << "There were  " << ten << " 'tens' entered" << endl; 
This question has already been answered. Start a new discussion instead.