Searching for "palindrome"

Q:

C program to find whether a number is palindrome or not.

Answer

 #include<stdio.h>
int main(){
    int num,r,sum=0,temp;

    printf("Enter a number: ");
    scanf("%d",&num);

    temp=num;
    while(num){
         r=num%10;
         num=num/10;
         sum=sum*10+r;
    }
    if(temp==sum)
         printf("%d is a palindrome",temp);
    else
         printf("%d is not a palindrome",temp);

    return 0;
}

Sample output:
Enter a number: 131
131 is a palindrome

Report Error

View answer Workspace Report Error Discuss

Subject: Programming

Q:

Consider the word ROTOR. Whichever way you read it, from left to right or from right to left, you get the same word. Such a word is known as palindrome. Find the maximum possible number of 5-letter palindromes.

A) 17756 B) 17576
C) 12657 D) 12666
 
Answer & Explanation Answer: B) 17576

Explanation:

The first letter from the right can be chosen in 26 ways because there are 26 alphabets.

 

Having chosen this, the second letter can be chosen in 26 ways

 

The first two letters can chosen in 26 x 26 = 676 ways

 

Having chosen the first two letters, the third letter can be chosen in 26 ways.

 

All the three letters can be chosen in 676 x 26 =17576 ways.

 

It implies that the maximum possible number of five letter palindromes is 17576 because the fourth letter is the same as the second letter and the fifth letter is the same as the first letter.

Report Error

View Answer Report Error Discuss