Check this:
int is_pal(int start, int end, string &str) { if (start >= end) return 1; if (str[start] != str[end]) return 0; return is_pal(++start, --end, str); }
Call the method from main. Let me know if that helps.. 🙂
Related Posts:
- how to implement quick sort algorithm in C++
- Exception in thread “main” java.lang.StackOverflowError
- Determining complexity for recursive functions (Big O notation)
- Java recursive Fibonacci sequence
- Print singly linked list in reverse order
- Understanding Recursion to generate permutations
- MIPS Recursive Fibonacci Sequence
- What exactly is the difference between “pass by reference” in C and in C++?
- What is `CString`?
- Binary Search Tree Implementation in C++ STL?
- Difference between != and =! with an example(in C++)
- Unresolved external symbol in object files
- How do sizeof(arr) / sizeof(arr[0]) work?
- The Definitive C++ Book Guide and List
- rand() between 0 and 1
- how to implement Interfaces in C++?
- What is the proper declaration of main in C++?
- What exactly is nullptr?
- How to make a SIMPLE C++ Makefile
- finding dll for “The specified module could not be found”
- no matching function for call to ‘ ‘
- Read file line by line using ifstream in C++
- Convert an int to ASCII character
- invalid conversion from ‘const char*’ to ‘char*’
- Evaluate a string with a switch in C++ [duplicate]
- Expected initializer before function name
- Inheriting constructors
- Pass a vector by reference C++
- lvalue required as left operand of assignment – Array
- What is uintptr_t data type
- Why do we use volatile keyword? [duplicate]
- C++ round a double up to 2 decimal places
- Windows 7 exception code: 0xc0000409
- Convert float to std::string in C++
- What is the maximum recursion depth in Python, and how to increase it?
- “items list” or “item list”
- When and why do I need to use cin.ignore() in C++?
- What does int & mean
- Evaluate a string with a switch in C++ [duplicate]
- “&” meaning after variable type
- How can I create objects while adding them into a vector?
- undefined reference to ‘std::cout’
- warning: control may reach end of non-void function
- Error at constructor : Expected an identifier?
- identifier “string” undefined?
- What does LPCWSTR stand for and how should it be handled with?
- A warning – comparison between signed and unsigned integer expressions
- C++ network programming
- new types may not be defined in a return type – C++
- Is the practice of returning a C++ reference variable evil?
- How to convert C++ Code to C
- How can I print out C++ map values?
- how to convert C# to C++
- What are helper functions in C++?
- How to fix ‘std::logic_error’ what(): basic_string::_M_construct null not valid error?
- C++ String Variable Declaration
- How to fix ‘std::logic_error’ what(): basic_string::_M_construct null not valid error?
- Eclipse C++ : “Program “g++” not found in PATH”
- Why is my HelloWorld function not declared in this scope?
- What is the difference between include_directories and target_include_directories in CMake?
- Recursion vs. Iteration (Fibonacci sequence)
- Undefined reference to constructor
- How to initialize a vector of pointers
- C++: Using ifstream with getline();
- How to add element to C++ array?
- expected constructor, destructor, or type conversion before ‘(’ token
- Passing as const and by reference – Worth it?
- expression did not evaluate to a constant- c++
- Generate SHA256 in c++
- A good and basic implementation of BigInt class in C++
- What is the C equivalent to the C++ cin statement?
- What does the fpermissive flag do?
- Convert char array to single int?
- https://stackoverflow.com/questions/3865946/error-generic-array-creation
- C++ variable has initializer but incomplete type?
- Does C++11 have C#-style properties?
- How to print a string in C++
- How to check if input is numeric in C++
- C++ Big Integer
- How do I create a random alpha-numeric string in C++?
- Learning to work with audio in C++
- C++ Void Function with File Stream Error
- sorting in std::map where key is a std::string
- System not declared in scope?
- What is predicate in C++?
- no debugging symbols found when using gdb
- C++ Array of pointers: delete or delete []?
- ERROR: Control may reach end of non-void function /
- Function stoi not declared
- Is null reference possible?
- Negative RGB Values
- DEV C ++ Error: expected declaration before ‘}’ token
- “cannot be used as a function error”
- error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup
- Displaying contents of a vector container in C++
- Converting string to unsigned int returns the wrong result
- Visual c++ can’t open include file ‘iostream’
- How to use bitmask?
- How do I check if a Key is pressed on C++
- -Error reading characters of string