-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy path5.cpp
43 lines (32 loc) · 766 Bytes
/
5.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// 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");
}
}