Check whether the given floating point number is a palindrome Last Updated : 13 Aug, 2021 Summarize Comments Improve Suggest changes Share Like Article Like Report Given a floating-point number N, the task is to check whether it is palindrome or not. Input: N = 123.321 Output: YesInput: N = 122.1 Output: No Approach: First, convert the given floating-point number into a character array.Initialize the low to first index and high to the last index.While low < high: If the character at low is not equal to the character at high then exit and print "No".If the character at low is equal to the character at high then continue after incrementing low and decrementing high...If the above loop completes successfully then print "Yes". Below is the implementation of the above approach: C++ // C++ implementation of the approach #include <bits/stdc++.h> using namespace std; // Function that returns true if num is palindrome bool isPalindrome(float num) { // Convert the given floating point number // into a string stringstream ss; ss << num; string s; ss >> s; // Pointers pointing to the first and // the last character of the string int low = 0; int high = s.size() - 1; while (low < high) { // Not a palindrome if (s[low] != s[high]) return false; // Update the pointers low++; high--; } return true; } // Driver code int main() { float n = 123.321f; if (isPalindrome(n)) cout << "Yes"; else cout << "No"; return 0; } // This code is contributed by Rajput-Ji Java // Java implementation of the approach public class GFG { // Function that returns true if num is palindrome public static boolean isPalindrome(float num) { // Convert the given floating point number // into a string String s = String.valueOf(num); // Pointers pointing to the first and // the last character of the string int low = 0; int high = s.length() - 1; while (low < high) { // Not a palindrome if (s.charAt(low) != s.charAt(high)) return false; // Update the pointers low++; high--; } return true; } // Driver code public static void main(String args[]) { float n = 123.321f; if (isPalindrome(n)) System.out.print("Yes"); else System.out.print("No"); } } Python3 # Python3 implementation of the approach # Function that returns true if num is palindrome def isPalindrome(num) : # Convert the given floating point number # into a string s = str(num) # Pointers pointing to the first and # the last character of the string low = 0 high = len(s) - 1 while (low < high): # Not a palindrome if (s[low] != s[high]): return False # Update the pointers low += 1 high -= 1 return True # Driver code n = 123.321 if (isPalindrome(n)): print("Yes") else: print("No") # This code is contributed by ihritik C# // C# implementation of the approach using System; class GFG { // Function that returns true // if num is palindrome public static bool isPalindrome(float num) { // Convert the given floating point number // into a string string s = num.ToString(); // Pointers pointing to the first and // the last character of the string int low = 0; int high = s.Length - 1; while (low < high) { // Not a palindrome if (s[low] != s[high]) return false; // Update the pointers low++; high--; } return true; } // Driver code public static void Main() { float n = 123.321f; if (isPalindrome(n)) Console.WriteLine("Yes"); else Console.WriteLine("No"); } } // This code is contributed by AnkitRai01 JavaScript <script> // Javascript implementation of the approach // Function that returns true if num is palindrome function isPalindrome(num) { // Convert the given floating point number // into a string var s = num.toString(); // Pointers pointing to the first and // the last character of the string var low = 0; var high = s.length - 1; while (low < high) { // Not a palindrome if (s[low] != s[high]) return false; // Update the pointers low++; high--; } return true; } // Driver code var n = 123.321; if (isPalindrome(n)) document.write( "Yes"); else document.write( "No"); </script> Output: Yes Time Complexity: O(N).Auxiliary Space: O(1). Comment More infoAdvertise with us Next Article Check whether the given floating point number is a palindrome S sunilkannur98 Follow Improve Article Tags : Strings Data Structures Programming Language DSA Arrays palindrome Numbers +3 More Practice Tags : ArraysData StructuresNumberspalindromeStrings +1 More Similar Reads Check whether given floating point number is even or odd Given a floating-point number, check whether it is even or odd. We can check whether a integer is even or odd by dividing its last digit by 2. But in case of floating point number we can't check a given number is even or odd by just dividing its last digit by 2. For example, 100.70 is an odd number 6 min read Check if a number is Palindrome in PL/SQL Given an integer, write a function that returns true if the given number is palindrome, else false. For example, 12321 is palindrome, but 1451 is not palindrome. Let the given number be num. A simple method for this problem is to first reverse digits of num, then compare the reverse of num with num. 1 min read Bash program to check if the Number is a Palindrome Given a number num, find whether the given number is palindrome or not using Bash Scripting. Examples: Input : 666 Output : Number is palindrome Input : 45667 Output : Number is NOT palindrome Approach To find the given number is palindrome just check if the number is same from beginning and the end 1 min read Check if a Number is Palindromic Prime A palindromic prime (sometimes called a palprime) is a prime number that is also a palindromic number. Given a number n, print all palindromic primes smaller than or equal to n. For example, If n is 10, the output should be â2, 3, 5, 7'. And if n is 20, the output should be â2, 3, 5, 7, 11'.Idea is 15 min read Program to check the number is Palindrome or not Given an integer N, write a program that returns true if the given number is a palindrome, else return false. Examples: Input: N = 2002 Output: trueInput: N = 1234Output: false Recommended: Please solve it on âPRACTICE â first, before moving on to the solution. Approach: A simple method for this pro 10 min read Like