- 2
String Palindrome in C..
Does anybody knows how to check palindrome for string in C language using for loop
2 Answers
+ 1
Ajas Mohammed
post your try?
reverse of string is equal to original string then it is polindrome.
using a loop,
check chat array i= first character 0th, with last character (j = length-1), if same continue to repeat this until not same or until i < j.
+ 1
bool isPalindrome(int x) {
int temp = x, reverse = 0;
while (temp != 0)
{
reverse = reverse * 10;
reverse = reverse + temp % 10;
temp = temp / 10;
}
if (x == reverse) return 1;
else return 0;
}