how to directly convert char to numbers?

Palindromic Numbers Please hElp C++?

  • My new version codes are supposed to include these expressions and I dont know what to do// bool ispalindrome(char[]); Palindromic number equals itself when its digits are reversed. Examples: 101, 2112, 12321. bool isrepdigit(char[]); The digits of a repdigit number are all the same. Repdigit numbers must have at least two digits. Examples: 22, 111, 444, 999999. bool isundulating(char []); An undulating number has the digit form aba, abab, ababa..., where a != b. Examples: 101, 121, 6969, 12121. void scramble(char[] orig, char[] new); convert odd digits into nothing convert 0 into a convert 2 into e convert 4 into i convert 6 into o convert 8 into u these are my codes please help// #include <iostream> #include<cstdlib> #include<cctype> #include<cstring> using namespace std; void Reverse(char name[]); int main(int, char**) { int EXIT_VALUE = 0; char strn[80]; char arr[80]; bool flag=false; do{ cout<<"Enter a positive integer ("<<EXIT_VALUE<<") to exit: "; cin>>strn; if(atoi(strn)<0){ cout<<"*** error: inputs must be greater than zero"<<endl<<endl; continue; }else if (!isdigit(strn[0])) { cout << "*** error: inputs must be an integer" << endl<<endl; continue; } strcpy(arr,strn); Reverse(arr); if(strcmp(arr,strn)==0) { flag=true; } if(flag){ cout<<strn<<" is a Palindrome"<<endl<<endl; }else{ cout<<strn<<" is not a Palindrome"<<endl<<endl; } flag=false; }while(strcmp("0",strn)!=0); return 0; } void Reverse(char name[]) { // get the length of the current word in the array index int nameLength = strlen(name)-1; for (int currentChar=0; currentChar < nameLength; --nameLength, ++currentChar) { // copy 1st letter in the array index into temp char temp = name[currentChar]; // copy last letter in the array index into the 1st array index name[currentChar] = name[nameLength]; // copy temp into last array index name[nameLength] = temp; } }

  • Answer:

    I'm not exactly sure what it is you are asking... What is it that you don't understand? Based on what I see you look like you are on a roll, so where is the problem?

Lebron at Yahoo! Answers Visit the source

Was this solution helpful to you?

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.