Created
October 5, 2018 23:29
-
-
Save milon120203/ca7e277c8e7fa368a055ae0fc025b53f to your computer and use it in GitHub Desktop.
Palindrome test in C
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/****************************************************************************** | |
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