Skip to main content

Posts

Showing posts with the label Palindrome

Print all the intermediate palindrome numbers between a given lower limit and upper limit

What is a palindrome number ? Check here   Java 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 import java.util.Scanner; public class PalindromeRange{ public static void main (String []args){ Scanner sc = new Scanner(System. in ); int lower = sc. nextInt (); int upper = sc. nextInt (); for ( int i=lower; i<=upper; i++){ if (checkPalindrome(i)) System. out . print (i + " " ); } } public static boolean checkPalindrome ( int n){ int temp = n, rev = 0 ; while (temp!= 0 ){ rev = (rev * 10 ) + (temp % 10 ); temp = temp / 10 ; } if (n==rev) return true ; return false ; } } Python lower = int ( input ( "Enter lower limi...

Print Palindromic number pattern with stars

Q.  if rows = 5 * 1 * * 1 2 1 * * 1 2 3 2 1 * * 1 2 3 4 3 2 1 * * 1 2 3 4 5 4 3 2 1 * Java Python

Check if a number is Palindrome or not

A number or string is said to be palindrome if it remains the same after reversing it.  Java Python

Check a string is palindrome or not

 A string is said to be a  palindrome if the string remains the same after reversing. eg.-  - code (after reversing the string " code " it becomes " edoc ")  so, the given string " code " is not a palindrome. - madam (after reversing the string  " madam " it becomes " madam ")  so, the given string " madam " is a palindrome. Java 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 import java.util.Scanner; public class CheckStringPalindrome { public static void main (String[] args) { Scanner sc = new Scanner(System. in ); String str = sc. nextLine (); StringBuffer sb = new StringBuffer(str); sb. reverse (); String rev = new String(sb); if (str. equals (rev)) { System. out . println ( "String is Palindrome" ); ...