Palindrome and prime functions errors

Oct 20, 2017 at 7:37pm
So i am working with code that has to do several things. It must add all of the digits of a randomly generated integer, reverse those digits, and also determine if the integer is a palindrome and if it is a prime number. I have this and I am getting a few errors and can not figure out exactly what I am doing wrong (except the part to determine if the integer is prime i don't think I did that correctly).

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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
  #include <iostream>
#include <iomanip>
#include <cstdlib>
#include <ctime>

using namespace std;

const int NUM_VALS = 10;       //the maximum number of values to use

/********* Put the function prototypes below this line *********/

void sumDigits(int number){
    if(number < 10) cout << number;
    else{
        cout << number%10 + (number / 10);
    }
}
void reverse(int number){
    if(number < 10) cout << number;
    else{
        cout << number%10;
        reverse(number / 10);
    }
}
bool isPalindrome( int number, int reverse)
{
    if (reverse(number));
        return (number = (reverse) % 10);
    else if (isPalindrome(number/10, reverse))
        return false;
    
    reverse /= 10;
    return (number % 10 == (reverse) % 10);
    
}

bool isPrime(int number);
{
    if(number%2!=0)
        return true
    else
        return false
}




int main()
{
    int number,          //holds the random number that is manipulated and tested
    loopCnt;         //controls the loop
    
    //set the seed value for the random number generator
    //Note: a value of 1 will generate the same sequence of "random" numbers every
    //      time the program is executed
    
    srand(31);
    
    
    //Generate 10 random numbers to be manipulated and tested
    
    for( loopCnt = 1; loopCnt <= NUM_VALS; loopCnt++ )
    {
        //Get a random number
        number = rand();
        
        //Display the sum of adding up the digits in the random number, the reversed
        //random number, and whether or not the number is palindromic or a prime number
        
        cout << "The number is " << number << endl
        << "----------------------------------------" << endl
        << "Adding the digits result" << setw(16) << sumDigits(number) << endl
        << "Reversing the digits result" << setw(13) << reverse(number) << endl
        << "Is the number a palindrome?" << setw(13) << (isPalindrome(number)? "Yes" : "No") << endl
        << "Is the number prime?" << setw(20) << (isPrime(number)? "Yes" : "No") << endl
        << endl << endl;
    }
    
    
    
    
    return 0;
}


Oct 20, 2017 at 8:16pm
I have this and I am getting a few errors

Maybe read this first.
http://www.dreamincode.net/forums/blog/2165/entry-4473-where-is-my-error/
Oct 20, 2017 at 8:53pm
I don't post here unless i've exhausted my efforts elsewhere. I have found solutions to my errors and explanations but none of them work for me or they are not relevant to my code. I wouldn't learn anything if i simply posted here without trying myself at first. Its in the beginner section because i am a beginner. Things that might be obvious fixes to you are not for me. Only been in a college coding class for a month.
Oct 21, 2017 at 7:16am
Making mistakes is ok and part of the learning process. In order to get help you need to provide information so that people know what to look for. Just dumping a load of code doesn't work.

First step I recommend is to compile your code and paste all the error messages in original.
Topic archived. No new replies allowed.