0

Plz help me code project Friend's

Shobha Vadla

19th May 2021, 5:44 AM
Shobha Vadla
Shobha Vadla - avatar
8 ответов
+ 6
Specify language and post your attempt.
19th May 2021, 5:45 AM
TOLUENE
TOLUENE - avatar
+ 3
#include <iostream> using namespace std; bool isPalindrome(int a) { //complete the function int rev=0,r; int temp; temp=a; bool ans; while(a>0) { r=a%10; rev=rev*10+r; a=a/10; } if(temp==rev) { ans=true; } else { ans=false; } return ans; } int main() { int n; cin>>n; if(isPalindrome(n)) { cout <<n<<" is a palindrome"; } else { cout << n<<" is NOT a palindrome"; } return 0; } Try this!!
19th May 2021, 5:51 AM
sarada lakshmi
sarada lakshmi - avatar
+ 2
Since you didn't specify the language, I can give you the hint. Use reverse logic and compare the original and reverse value. If it's true then palindrome, else not.
19th May 2021, 5:46 AM
sarada lakshmi
sarada lakshmi - avatar
+ 2
You're writing the whole logic in main(). Then what's the use of declaring a function??
19th May 2021, 5:49 AM
sarada lakshmi
sarada lakshmi - avatar
+ 1
include <iostream> using namespace std; bool isPalindrome(int x) { //complete the function } int main() { int n; reversedInteger = 0, remainder, originalInteger; } cin >>n; originalInteger = n; while( n!=0) { remainder = n%10; reversedInteger = reversedInteger* 10 + remainder ; n/= 10; } if (originalInteger == revetsedInteger) { cout <<originalInteger
19th May 2021, 5:47 AM
Shobha Vadla
Shobha Vadla - avatar
+ 1
What is in the code any wrong plz tell me
19th May 2021, 5:48 AM
Shobha Vadla
Shobha Vadla - avatar
+ 1
Int
19th May 2021, 5:50 AM
Shobha Vadla
Shobha Vadla - avatar