write a user defined function to check whether the given number is a palindrome or not.@ write a user defined function to check whether the given number is a palindrome or not.@ @Computer Science
pls help me...
#include<iostream.h> #include<conio.h> void main() { clrscr(); { int palindrome(int n)
wt to do next??
:)
pal
hey...:)
:)
pls help...
njano?
ohh...i havent studied that...:(
wndrful
poda arvind...
NJAN HELP CHEYAMEDI
then help pls.....:(
cm thrr
k u knw prgrm of palindrome?
yupz..
pinenetha prblm?
user defined function....idk that
scoolil eduthile?
cin>>num; n=num; digit =num%10; rev=(rev*10)+digit; num=num/10; while(num!=0); if(n==rev); numbr is palindrome
lol...skul..hehe they teach-2+5 hw-23^34xi+243i exam-86^(110x)-36/23i+45^57*97^i
???
just kiddin ;)
:)
aa prgrm type cheyan kure neram pidikum
datz okie...i'l wait
podi eniku atrem type cheyan patila
ehhh.....:(
temmme u dunno...:P
ariyamedi poti
pkshe type cheyan samayamila sry
heyy...b descent..k?
k den ....will luk 4 sm1 else....
:D
ey i cal my gud frnds lyk tht u dnt lyk it??
hmmm....
?
hey...u knw any user defined functions?? lowercase to uppercase??
ya toupper
bt to use tht u need to include character.h file or smthng
string.h i think
mmm...nt needed...din study dat chptr..
So, first thing is first. I'm assuming you're using C++ because you use "cin" in some of your code samples. So, if you already have something along the lines of: string numberstring; cin >> numberstring; And you need to determine if that is a palindrome, then you need to do something like this in a different function: for(i=0; i < (numberstring.length/2); i++) { if(numberstring[i] != numberstring[numberstring.length-i]) { return false; } } return true; Granted, I'm not a C/C++ programmer primarily, so you'll likely need to do some adjustments for off-by-one errors. But the general idea is to use one loop to check the string from both ends at the same time. Because it's a string, you can do that. If you're required to start with an integer, then you'll need to do some conversion before that loop will work.
what does return false , return true mean??
Well, the assumption was that this code would be inside some function that returns a boolean value (true/false value). So, true would mean the number is a palindrome, false would mean the number isn't a palindrome. You can replace those lines with whatever else makes sense for your particular program.
k...tnk u :)
Hi i want 1 simple Question answers Write a program that uses function digit(N,k) that return the value of the kth digit from the right of the number N. For eg. The function call digit (254693,2) should return 9.
Join our real-time social learning platform and learn together with your friends!