C Write a program that uses a recursive function to determin
C++
Write a program that uses a recursive function to determine whether a string is a character-unit palindrome. Moreover, the options for doing case sensitive comparisons and not ignoring spaces are indicated with flags. For example \"A nut for a jar of tuna\" is a palindrome if spaces are ignored and not otherwise. \"Step on no pets\" is a palindrome whether spaces are ignored or not, but is not a palindrome if it is case sensitive. Background Palindromes are character sequences that read the same forward or backward (e.g. the strings \"mom\" or \"123 454 321\"). Punctuation and spaces are frequently ignored so that phrases like \"Dog, as a devil deified, lived as a god.\" are palindromes. Conversely, even if spaces are not ignored phrases like \"Rats live on no evil star\" are still palindromes.
Requirements
Command Line Parameters
The program name will be followed by a list of strings. The program will determine whether each string is a palindrome and output the results. Punctuation will always be ignored. An optional flag can preceed a term that modifies how the palindrome is determined.
Strings
Each string will be separated by a space on the command line. If you want to include a string that has spaces in it (e.g. \"Rats live on no evil star\"), then put quotes around it. The quote characters will not be part of the string that is read in.
Flags
Optional for the user Must immediately precede the word it applies to. Must start with a minus (-) sign followed by one or two flag values that can be capital or lower case. e.g. -c, -S, -Cs, -Sc, etc. There are no spaces between starting minus (-) sign and flag(s). Flags values are case insensitive. c or C: Indicates that comparisons should be case-sensitive for all input strings. The default condition (i.e. if the flag is NOT included) is to ignore case-sensitivity. So, for example: palindrome Mom should evalate as being a palindrome. palindrome -c Mom should not evalate as being a palindrome. s or S: Indicates that comparisons should not ignore spaces for all input strings. The default condition (i.e. if the flag is NOT included) is to ignore spaces. So, for example: palindrome \"A nut for a jar of tuna\" should evalate as being a palindrome. palindrome -s \"A nut for a jar of tuna\" should not evalate as being a palindrome. Options can appear in different flags, e.g. you can use -Sc or -S -c The same flag cannot appear more than one time prior to a term. If it does, print a usage statement and exit program.
Code Expectations
Program should only get user input from the command line. (i.e. \"cin\" should not be anywhere in your code). Required Functions:printUsageInfo - Print program usage message in case no input strings were found at command line. Parameter(s): a string representing the name of the executable from the command line. Return: void. isPalindrome - This function determines whether a string is a character-unit palindrome. Parameter(s): an input string, and two boolean flags that say whether to consider case-sensitivity and whether to not ignore spaces. Return: bool. All functions should be placed in a separate file following the conventions we covered.
Program Flow
Your program will take arguments from the command-line. Determine if you have enough arguments. If not, output a usage message and exit program. Loop through all arguments:Determine if a flag or a term.If flag Process and set values to use when processing a palindrome. If flag set too many times, e.g. -s -S or -scs, print usage message and exit program immediately. If term: Process by calling isPalindrome function with flag values. Output results
Any time you encounter a syntax error, you should print a usage message and exit the program immediately.
Solution
bool is_palindrome(const char *phrase, unsigned length) {
const char *s = phrase + 0;
const char *e = phrase + length - 1;
while (s < e) {
if (*s != *e)
return false;
s += 1;
e -= 1;
}
return true;
}
bool is_palindrome_case(const char *phrase, unsigned length) {
const char *s = phrase + 0;
const char *e = phrase + length - 1;
while (s < e) {
if (toupper(*s) != toupper(*e))
return false;
s += 1;
e -= 1;
}
return true;
}
bool is_palindrome_space(const char *phrase, unsigned length) {
const char *s = phrase + 0;
const char *e = phrase + length - 1;
while (s < e) {
if (!isalnum(*s)) {
s++;
} else if (!isalnum(*e)) {
e--;
} else if (toupper(*s) == toupper(*e)) {
s++;
e--;
} else {
return false;
}
}
return true;
}
all the methods for doing all the option.
just need a string comparision for correct option of the requorement command.
writing switich condition and calling method of requirment basis.

