Question:Palindrome in c without using string function 

Answer 
#include<stdio.h>

int main(){
  char str[100];
  int i=0,j=-1,flag=0;

  printf("Enter a string: ");
  scanf("%s",str);

  while(str[++j]!='\0');
  j--;

  while(i<j)
      if(str[i++] != str[j--]){
           flag=1;
           break;
      }
     

  if(flag == 0)
      printf("The string is a palindrome");
  else
      printf("The string is not a palindrome");

  return 0;
}
 

+ Report
Total Preview: 682
Palindrome in c without using string function
Copyright © 2024. Powered by Intellect Software Ltd