input: 8732 desired output: 2378 not sure why it isn\'t printing the value backw
ID: 3609323 • Letter: I
Question
input: 8732desired output: 2378
not sure why it isn't printing the value backwards, if you couldgive me a hand that would be good.
#include <cstdlib>
#include <iostream>
using namespace std;
/**
* Prototypes
*/
bool invert(int &n);
/**
* This program will read a positive integer number, invert itand print
* the new number.
*/
int main(int argc, char *argv[])
{
// Variables declaration
int num;
// Get a value for n
cout << "Enter an integer number (n>0):";
cin >> num;
// Invert the number and print the result
invert(num);
if (num<=0){
cout << "Invalid number."<<endl;}
else{
cout << "The number "inverted" is: "<< num << endl;}
system("PAUSE");
}
bool invert(int &n)
{
int inv = 0, dig;
if (n<=0){
return false;}
else{
for (inv;inv<n;inv++){
for(inv=n-1;inv>=0;inv--)
return true;}
}}