Write a program containing a function, reverseDigit, that takes an integer as a parameter and returns the number with its digits reversed, then printout the return result. For example, the value of reverseDigit(12345) is 54321; the value of reverseDigit(5600) is 65; the value of reverseDigit(7008) is 8007; and the value of reverseDigit(-532) is -235.
Modify the following program to make a correct output.
/*
// Name: Your Name
// ID: Your ID
// Purpose Statement: ~~~
*/
#include <iostream>
using namespace std;
int reverseDigit(int num);
int main ()
{
int num;
cout << "Enter an integer: ";
…
…
…
cout << ~~~
<< "The return value is " ~~~
<< endl;
return 0;
}
int reverseDigit(int num)
{
int reverseNum = 0;
…
…
…
return reverseNum;
}
#include <iostream>
using namespace std;
int reverseDigit(int num);
int main (){
int num;
cout << "Enter an integer: ";
cin>>num;
cout <<"The return value is "<<reverseDigit(num)<< endl;
return 0;
}
int reverseDigit(int num){
int reverseNum = 0;
while(num>0){
reverseNum=reverseNum * 10 + (num%10);
num=num/10;
}
return reverseNum;
}
NOTE : PLEASE COMMENT BELOW IF YOU HAVE CONCERNS.
I AM HERE TO HELP YOUIF YOU LIKE MY ANSWER PLEASE RATE AND HELP ME IT IS VERY IMP FOR ME
Get Answers For Free
Most questions answered within 1 hours.