Q; FLOW007 Problem - CodeChef
P; https://onlinegdb.com/HytHrDiAS
what’s the mistake in it ?
@aditigedam Use this equation to reverse the number:
reverse_num = 0
reverse_num = reverse_num * 10 + number % 10
then update your number as:
number = number / 10
Run the above instructions under a loop until number becomes 0.
You will have an answer in reverse_number
when the loop terminates.
Refer to the source-code below:
#include<bits/stdc++.h>
using namespace std;
static unsigned int compute_reverse_number(unsigned int);
int main(void) {
int test;
std :: cin >> test;
while(test--) {
unsigned int n;
std :: cin >> n;
std :: cout << compute_reverse_number(n) << endl;
}
return 0;
}
static unsigned int compute_reverse_number(unsigned int n) {
unsigned int reverse_number = 0;
while(n) {
reverse_number = (10 * reverse_number) + (n % 10);
n /= 10;
}
return reverse_number;
}
took your code and made few corrections on top of it, issue is you are ignoring zero’s where ever they are occuring.
check this solution solution