Working on Palindrome program

I was looking on some forums but at the moment i cant find someone that help me. I am making an homework for C++ about Calculate the palindrome of a number and a number or interactions to get the palindrome.

Explain of code that we have at the moment: first we declare a string variable, when program runs, it prompt the user to enter the number to check for palindome, then we calculate the string size and we start a for loop for reverse the number(string). Then we use the atoi for convert the both string to int (The normal num, and the reversed number) and then we can SUM the 2 values. And we put the value of the sum to another variable int sum_num . Now we need to convert sum_num from int to string for calculate again the palindrome and check how many times we need to repeat the loop for calculate the palindrome. Please help


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <iostream>
#include <string>
#include <iomanip>


using std::atoi; //necesario para convertir strings a int
using namespace std;

int main() {
    
   int num1,num2,sum_num;
    string numero;
    string reverse;
    string sum_str;
    int caracteres;
 
    cout<<"\nEnter the number to find 'Palindrome' :  ";
   
 getline(cin,numero);
        
    caracteres=(numero.size()); //calculate the string leght
    
        for(int j=caracteres-1; j>=0; j--){
               reverse=reverse+numero.at(j);           
         }
     num1=atoi(numero.c_str()); //tranfer from string to int
     num2=atoi(reverse.c_str()); //transfer from string to int
     sum_num=num1+num2; //sum both numbers, the normal and the reversed
  
  


    system("pause");
    return 0;
 }
Topic archived. No new replies allowed.