Skip to content

Instantly share code, notes, and snippets.

@milon120203
Created October 5, 2018 23:29
Show Gist options
  • Save milon120203/ca7e277c8e7fa368a055ae0fc025b53f to your computer and use it in GitHub Desktop.
Save milon120203/ca7e277c8e7fa368a055ae0fc025b53f to your computer and use it in GitHub Desktop.
Palindrome test in C
/******************************************************************************
Online C Compiler.
Code, Compile, Run and Debug C program online.
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
#include <stdio.h>
#include<string.h>
int main()
{
char str[25];
printf("Enter String:");
scanf("%s",&str);
int i,count=0;
for (i=0; str[i]!='\0';i++)
{
//printf("%c", i);
count++;
}
printf("Length is: %d \n", count);
int first=0;
int last=count-1;
while (last>1)
{
if (str[first++]!=str[last--])
{
printf("%s is not palindrome", str);
return;
}
}
printf("%s is palindrome", str);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment