Skip to content

Instantly share code, notes, and snippets.

@Kimxons
Created April 17, 2021 19:41
Show Gist options
  • Save Kimxons/cf172282985a79f65c33cd40bcd02bb6 to your computer and use it in GitHub Desktop.
Save Kimxons/cf172282985a79f65c33cd40bcd02bb6 to your computer and use it in GitHub Desktop.
#include<stdio.h>
#include<string.h>
void palindrome(char str[])
{
int leftmost_index = 0;
int rightmost_index = strlen(str) - 1;
while(rightmost_index > leftmost_index)
{
if(str[leftmost_index++] != str[rightmost_index--])
{
printf("%s not a palindrome\n", str);
return;
}
}
printf("%s is a palindrome\n", str);
}
int main()
{
palindrome("mom");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment