No match for operator << error

So im doing a program where we generate a set of 10 random numbers and reverse the digits of each number, add the digits, and then determine if it is palindrome and if it is prime. In line 70 im getting the no match for operator << error. The problem is that that part of the code was provided to us by the professor so im not sure how there would be an error. If anyone can help me with what im missing that would be great. And if anyone can help me figure out how to do the palindrome correctly that would also be great because ive tried several functions but none of them work right

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
#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 isprime(int number)
{
     int i,count=0;
     if(number==1)
      return false;
	 if(number==2)
      return true;
     if(number%2==0)
      return false;
     for(i=1;i<=number;i++)
      if(number%i==0) count++;
      if(count==2)  
       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;
}
Last edited on
sumDigits has a return type of void. You need to put the call to it in its own statement.
Topic archived. No new replies allowed.