Hi everyone, I've been taking a class on cprogramming and have been successful up until classes. I am now learning about stacks but was told to apply it to the program below so that the output

1

2

3

4

will print out

4

3

2

1

I understand the concept in which the output will first be stored in an array [1,2,3,4] but am not entirely sure on how to retreive it without making the program really long. I know about pop functions but have only used this with push empty and full functions in class. I am just having problems on trying to figure out how to implement it here. Will I have to use a pop function to remove the numbers from top to bottom and then print them out that way? Can I complete this by just adding the pop function. please let me know if you have any suggestions

Any help will be greatly appreciated

Thanks

Code:#include * "" "" using namespace std; const string space = ""; void primefactor(int number); bool isprime(int number); int main() { int n; cout << "Enter a number > 1000 -> "; cin >> n; primefactor(n); return 0; } void primefactor(int n) { bool truePrime = trueprime(n); int prime = n; int i = 2, j; double squareRoot = sqrt(static_cast<double>(n)); int count = 0; cout << "The prime factorization of " << n << " is:" << endl; if(truePrime) cout << space << n << " is a prime number." << endl; else { while((prime > 0) && (i <= n)) { if((prime % i) == 0) { count++; for(j = 0; j < count; j++) cout << space; cout << i << " is a factor" << endl; prime /= i; } else i++; } } } bool trueprime(int n) { int i; for(i = 2; i < n; i++) { if((n % i) == 0) return false; } return true; }