Skip to content

Commit

Permalink
Create 8. check if a string is a palindrome or not.c
Browse files Browse the repository at this point in the history
  • Loading branch information
shad-ct authored Oct 15, 2024
1 parent af3b5f2 commit 4d9147f
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions LabRecord/8. check if a string is a palindrome or not.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include <stdio.h>
#include <string.h>
int main(){
char name[100] = "malayalam";
int i , j,length=0,flag = 1;
while(name[length]!='\0'){ // process of strlen() , you can also do strlen(name);
length++;
}
for(i=0,j=length-1; i<j ; i++,j--){
if(name[i]!=name[j]){
flag = 0;
break;
}
}
if(flag == 1){
printf("pal");
}
else{
printf("not");
}
}

0 comments on commit 4d9147f

Please sign in to comment.