Ma'am ,if we consider a string like "moram". So then,we should not give break in this position.Because if(m!=m), condition false ,and then break statement help to terminate the loop ,and print both are same string.
Could u please give me the program to check wether the words in a given sentence are palindrome.if not reverse the word.print the new sentence right now ples? Fast.
If the first condition is true than it will loop through all until condition is false. But if the first or any next iteration is false it will break from loop before completion and give output as non palindrome.
actually there is no point in checking entire length of the string, half of it will do, it is c# but you all will get it :) static bool IsPalindrome(string text){ int len = text.Length; int halfLen = len /2; len -= 1; for(int i = 0; i < halfLen; i++){ if(text[i] != text[len - i]) return false; } return true; }
Easiest way to understand palindrome program int main(void) { int a,b,c,d,e,f; printf("Please Enter a 5 digit number: "); scanf("%d",&a); b=a/10000; c=a/1000; d=c%10; e=a%10; f=a%100/10; if(b==e && d==f) { printf("Your number is \"palindrome\" = %d ",a); } else { printf("Your number is \"NOT\" palindrome-%d ",a); } printf("Thank you!"); return 0; }