Q 4. Write a function, reverseDigit that takes an integer as a parameter and returns the number with its digits reversed. 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.
1
Expert's answer
2017-12-12T13:44:07-0500
#include <iostream>
using namespace std;
//begin task int reverseDigit(int val) { int res = 0; while (val != 0) { //move digits result to left res *= 10; //get last digit value res += val % 10; //next digit value val = val / 10; } return res; } //end task
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot
Comments
Dear Jetender Khatri, You're welcome. We are glad to be helpful. If you liked our service please press like-button beside answer field. Thank you!
Thanks you for help me.
Leave a comment