ะงะธัะปะฐ ะฟะฐะปะธะฝะดั€ะพะผั‹ | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

ะงะธัะปะฐ ะฟะฐะปะธะฝะดั€ะพะผั‹

ะะฐะฟะธัˆะธั‚ะต ั„ัƒะฝะบั†ะธัŽ, ะบะพั‚ะพั€ะฐั ะฒะพะทะฒั€ะฐั‰ะฐะตั‚ true, ะตัะปะธ ะดะฐะฝะฝะพะต ั‡ะธัะปะพ ัะฒะปัะตั‚ัั ะฟะฐะปะธะฝะดั€ะพะผะพะผ, ะธ false, ะตัะปะธ ะฝะต ัะฒะปัะตั‚ัั. ะ—ะฐะฒะตั€ัˆะธั‚ะต ะดะฐะฝะฝัƒัŽ ั„ัƒะฝะบั†ะธัŽ, ั‡ั‚ะพะฑั‹ ะบะพะด ะฒ main ั€ะฐะฑะพั‚ะฐะป ะธ ะฟั€ะธะฒะพะดะธะป ะบ ะพะถะธะดะฐะตะผะพะผัƒ ั€ะตะทัƒะปัŒั‚ะฐั‚ัƒ. ะŸั€ะธะผะตั€ ะ’ั…ะพะดะฝั‹ั… ะ”ะฐะฝะฝั‹ั…: 13431 ะŸั€ะธะผะตั€ ะ’ั‹ั…ะพะดะฝั‹ั… ะ”ะฐะฝะฝั‹ั…: 13431 is a palindrome ะ’ะพั‚ ั ั‡ั‚ะพ ะฝะฐะฟะธัะฐะป: #include <iostream> using namespace std; bool isPalindrome(int x) { //ะทะฐะฒะตั€ัˆะธั‚ะต ั„ัƒะฝะบั†ะธัŽ for(x=0; x>10; x++) cout<<x<<endl; } int main() { int n; cin >>n; if(isPalindrome(n)) { cout <<n<<" is a palindrome"; } else { cout << n<<" is NOT a palindrome"; } return 0; } The task says that I would complete the given function so that the code in main would work and lead to the expected result. As I understand it in main, I can't change anything.

17th Jan 2021, 7:24 PM
ะะปะตะบัะตะน
13 Answers
+ 4
do { digit = num % 10; rev = (rev * 10) + digit; num = num / 10; } while (num != 0); Ex -- the number 123, 3 is in the zeroth place, 2 in the oneth place and 1 in the hundredth place. So, to add another number 4 after 123, we need to shift the current numbers to the left, so now 1 is in the thousandth place, 2 in the oneth place, 3 is in the onethplace and 4 in the zeroth place. This is done easily by multiplying 123 by 10 which gives 1230 and adding the number 4, which gives 1234. The same is done in the code above. When the do while loop finally ends, we have a reversed number in rev. This number is then compared to the original number n. If the numbers are equal, the original number is a palindrome, otherwise it's not. Edit : If u still not getting this topic u required to do more work on math : ) Don't worry you will get it surely . Just keep going : ))
17th Jan 2021, 8:16 PM
Mr. Rahul
Mr. Rahul - avatar
+ 4
Decided everything #include <iostream> using namespace std; bool isPalindrome(int n) { //ะทะฐะฒะตั€ัˆะธั‚ะต ั„ัƒะฝะบั†ะธัŽ int n0= n, m = 0; while(n!=0) { m *= 10; m += n%10; n = n/10; } return (m == n0); } int main() { int n; cin >>n; if(isPalindrome(n)) { cout <<n<<" is a palindrome"; } else { cout << n<<" is NOT a palindrome"; } return 0; }
18th Jan 2021, 7:55 PM
ะะปะตะบัะตะน
+ 4
ะฏ ั€ะตัˆะธะป,ะฒะทัะป ั ะธะฝะตั‚ะฐ.ะšะพะด ะฟั€ะพัั‚ ะธ ะฟะพะฝัั‚ะตะฝ.ะ ะฒะฐัˆ ัั‚ะพ ะดั€ัƒะณะพะน ัƒั€ะพะฒะตะฝัŒ ะฝะฐะฒั‹ะบะพะฒ c++.ะฏ ะฝะพะฒะธั‡ะพะบ ะผะฝะต ะฝะฐะดะพ ะฟะพะบะฐ ะฟะพะฟั€ะพั‰ะต.ะ ะฒะฐัˆ ะบะพะด ะผะฝะต ะดะฐะถะต ะฝะต ััะตะฝ, ะบั€ะพะผะต ะฟะพัะปะตะดะฝะธั… 2 ัั‚ั€ะพะบ! ะœะฝะต ะดะฐะฒะฐะปะธ ั€ะฐะฑะพั‡ะธะน ะบะพะด, ะฝะพ ั‚ะพะปะบัƒ ะตัะปะธ ั ะตะณะพ ะฝะต ะฟะพะฝะธะผะฐัŽ.ะขะฐะบะธะผ ะพะฑั€ะฐะทะพะผ ะฝะต ั„ะธะณะฐ ะฝะต ัƒัะฒะพัŽ!.
18th Jan 2021, 8:46 PM
ะะปะตะบัะตะน
17th Jan 2021, 7:32 PM
Mr. Rahul
Mr. Rahul - avatar
+ 3
Mr.Rahul. The code works. But I have a different construction of the code. I'll try to build on your code.
17th Jan 2021, 8:02 PM
ะะปะตะบัะตะน
17th Jan 2021, 8:08 PM
Mr. Rahul
Mr. Rahul - avatar
+ 3
ะฏ ะฟั€ะตะดะปะฐะณะฐัŽ ัะดะตะปะฐั‚ัŒ ะดะฐะฝะฝัƒัŽ ั„ัƒะฝะบั†ะธัŽ ั‡ะตั€ะตะท ัั‚ั€ะพะบะธ. ะกะฝะฐั‡ะฐะปะฐ ะผั‹ ะบะพะฝะฒะตั€ั‚ะธั€ัƒะตะผ ั†ะตะปะพั‡ะธัะปะตะฝะฝั‹ะน ั‚ะธะฟ ะฒ ัั‚ั€ะพะบัƒ, ะพะฑั€ะฐั‰ะฐะตะผ ะตะต, ะบะพะฝะฒะตั€ั‚ะธั€ัƒะตะผ ะฒ int. ะ˜ ัั€ะฐะฒะฝะธะฒะฐะตะผ ั ะดะฐะฝะฝั‹ะผ ั‡ะธัะปะพะผ. #include <iostream> #include <string> #include <algorithm> using namespace std; //Compiler version g++ 6.3.0 bool palindrome(int x){ string str = to_string(x); reverse(str.begin(), str.end()); int x_reverse=stoi(str); if(x==x_reverse) return true; else return false; }
18th Jan 2021, 8:41 PM
ะŸะฐะฒะปะพ ะ“ะตั€ะฐัะธะผั‡ัƒะบ
+ 2
Login does not work on the forum site
17th Jan 2021, 7:44 PM
ะะปะตะบัะตะน
+ 2
That's not for you
17th Jan 2021, 7:52 PM
ะะปะตะบัะตะน
+ 2
No works
17th Jan 2021, 8:14 PM
ะะปะตะบัะตะน
+ 2
#include <iostream> using namespace std; bool isPalindrome(string x) { //ะทะฐะฒะตั€ัˆะธั‚ะต ั„ัƒะฝะบั†ะธัŽ for(int i=0; i<x.length()/2; ++i){ if(x[i] != x[x.length()-i-1]) return false; } return true; } int main() { string n; cin >>n; if(isPalindrome(n)) { cout <<n<<" is a palindrome"; } else { cout <<n<<" is NOT a palindrome"; } return 0; }
14th Sep 2021, 5:30 PM
ะะฝะดั€ะตะน ะ“ะฐะปะตะตะฒ
ะะฝะดั€ะตะน ะ“ะฐะปะตะตะฒ - avatar
+ 1
A palindromic number is a number (such as 626) that remains the same when its digits are reversed. Write a function that returns true if a given number is a palindrome, and false, if it is not. Complete the given function, so that the code in main works and results in the expected output. Sample Input: 13431 Sample Output: 13431 is a palindrome
17th Jan 2021, 7:26 PM
ะะปะตะบัะตะน
+ 1
The task says that I would complete the given function so that the code in main would work and lead to the expected result. As I understand it in main, I can't change anything. I need to write a function for the code in main to work with the function. A palindromic number is a number (such as 626) that remains the same when its digits are reversed. Write a function that returns true if a given number is a palindrome, and false, if it is not. Complete the given function, so that the code in main works and results in the expected output. Sample Input: 13431 Sample Output: 13431 is a palindrome
17th Jan 2021, 9:52 PM
ะะปะตะบัะตะน