C programPalindromes netbean IDE 81 Hi Im trying to code a P

C program-Palindromes (netbean IDE 8.1)

Hi, I\'m trying to code a Palindrome problem with some specifications. I\'m a beginner and I don\'t know how to use the function/pointers for this problem.

You may assume the message contains 100 or fewer characters. Therefore, define a global constant N equal to 101, since the last element of a character array must be a ‘\\0’ (the NULL character). Use N to declare your array of characters, and a while() loop with the getchar() function to read in characters into the array. Use a function called is_palindrome() that has the following function prototype: bool is_palindrome(int n, char array[n]); The function accepts the number elements within the array, and a character array as inputs. The function returns a TRUE or FALSE value that indicates whether or not the line is a palindrome. You must define two pointers to help you code your solution. The first pointer must initially point the 0th character in the character array, and the second pointer should point to the last character in the line. Then use the pointers to point toward different elements within the string and check to see if you have a palindrome. Ignore non-alpha characters. You may use the isalpha() and toupper() functions to help you.

Solution

#include <stdio.h>
#include <string.h>
#include <stdbool.h>

bool is_palindrome(int N, char array[N]);
int main(){
   int N = 10;
char string[N];
int i, length;
  
while (i<N){
   printf(\"Enter %d character :\",i);
   scanf(\"%c\", &string[i]);
   i = i+1;
}
if(is_palindrome(N,string)){
   printf(\"Palindrome.\ \");
}else{
   printf(\"not a Palindrome.\ \");
}
  
return 0;
}

bool is_palindrome(int N, char array[N]){
   int i,flag = 0;
   for(i=0;i < N ;i++){
if(array[i] != array[N-i-1]){
flag = 1;
break;
   }
   }
  
if (flag) {
return false;
}
else {
return true;
}
}

C program-Palindromes (netbean IDE 8.1) Hi, I\'m trying to code a Palindrome problem with some specifications. I\'m a beginner and I don\'t know how to use the

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site