When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
7 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
#include <iostream>
using namespace std;
int reverse (int number){
int prevrten=0;
while (number>0){
int temp=number;
int digit=temp%10;
prevrten=prevrten*10+digit;
number/=10;
}
return prevrten;
}
int isPalindrom (int number){
reverse (number);
if (number == reverse(number))
return number;
}
int findLargest(int start,int end){
int max=0;
for (int i = start; i <=end ; ++i) {
if (isPalindrom(i)>max)
max=i;
}
return max;
}
int main() {
int pochetok,kraj;
cin>>pochetok>>kraj;
int rezultat = findLargest(pochetok,kraj);
cout<<"Largest Palindromic Number: "<<rezultat;
return 0;
}
Prevrten means reverse, pochetok means beginning (of range), kraj means end (of range), rezultat means result
What's the issue?
I solved it
I just added return 0 in the isPalindrom function and it is working now
Mark it as solved too