so in the main function I want to call the bool function but I don't know how
You can use the following program:
#include <iostream>
using namespace std;
//forward declare the function
bool palindrome (string a);
int main() {
string a;
cout<<"Masukkan kata : ";
cin>> a;
if (palindrome(a) == true)//call the function and check the return value.
{
cout<<"Kata tersebut termasuk palindrome ";
}
else
cout<<"Kata tersebut tidak termasuk palindrome";
}
bool palindrome (string a) {
int b;
b= a.length();
if (b == 0)
return 1;
else if (a[0] != a[b - 1])
return 0;
else
return palindrome (a.substr(1, b - 2));
}
The output of the above program can be seen here.