Write a program that uses function isnumberpalindrome.Test your program on the following numbers 10,34,123454321,4444,5678765
[FONT="Arial Narrow"][/FONT]When i write a number greater than 10 the function does not return value 1(means no. is palindrome).Code:#include<iostream.h> #include<conio.h> #include<math.h> float isNumPalindrome(int x); int main() { int num; clrscr(); cout<<"\t******WELCOME******\n\n"; cout<<"1 means PALINDROME, 0 means not a PALINDROME\n"; cout<<"Enter Number to check whether its a PALINDROME="; cin>>num; num=isNumPalindrome(num); cout<<num<<endl; getch(); return 0; } float isNumPalindrome(int x) { int pwr=0; if (x<10) return 1; else { while (x/(pow(10,pwr)) >=10) pwr=pwr+1; while (x>=10) { if (x/pow(10,pwr) != (x % 10)) return 0; else { x = x / pow(10,pwr); x = x % 10; pwr = pwr-2; } } return 1; } }
I gues there is a logical error em stuck in it..kindly help..@@!!



LinkBack URL
About LinkBacks


