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
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <ctime>
usingnamespace std;
constint 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)
returnfalse;
if(number==2)
returntrue;
if(number%2==0)
returnfalse;
for(i=1;i<=number;i++)
if(number%i==0) count++;
if(count==2)
returntrue;
elsereturnfalse;
}
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;
}