Code 1:

1.

**Wap to check a number is palindrome**
2.

**C program to find whether a number is palindrome or****not**
#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

Code 2:

1.

**Write a c program for palindrome**
2.

**C program to find palindrome of a number**
3.

**Palindrome number in c language**
#include<stdio.h>

int main(){

int num,r,sum,temp;

int min,max;

printf("Enter
the minimum range: ");

scanf("%d",&min);

printf("Enter
the maximum range: ");

scanf("%d",&max);

printf("Palindrome
numbers in given range are: ");

for(num=min;num<=max;num++){

temp=num;

sum=0;

while(temp){

r=temp%10;

temp=temp/10;

sum=sum*10+r;

}

if(num==sum)

printf("%d
",num);

}

return 0;

}

Sample output:

Enter the minimum range: 1

Enter the maximum range: 50

Palindrome numbers in given range
are: 1 2 3 4 5 6 7 8 9 11 22 33 44

Code 3:

1.

**How to check**if**a number is a palindrome using**for**loop**
#include<stdio.h>

int main(){

int num,r,sum=0,temp;

printf("Enter a
number: ");

scanf("%d",&num);

for(temp=num;num!=0;num=num/10){

r=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: 1221

1221 is a palindrome

Code 4:

1.

**C program to check****if****a number is palindrome using recursion**
#include<stdio.h>

int
checkPalindrome(int);

int main(){

int num,sum;

printf("Enter a
number: ");

scanf("%d",&num);

sum
= checkPalindrome(num);

if(num==sum)

printf("%d is a palindrome",num);

else

printf("%d is
not a palindrome",num);

return 0;

}

int checkPalindrome(int num){

static int sum=0,r;

if(num!=0){

r=num%10;

sum=sum*10+r;

checkPalindrome(num/10);

}

return sum;

}

Sample output:

Enter a number: 25

25 is not a palindrome

**Definition of Palindrome number or**

**What is palindrome number?**

A number is called palindrome number if it is remain same when its digits are reversed. For example 121 is palindrome number. When we will reverse its digit it will remain same number i.e. 121

**Palindrome numbers examples**: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 22, 33, 44, 55, 66, 77, 88, 99, 101, 111, 121, 131, 141, 151, 161, 171, 181, 191 etc.

10. Write a c program to add two numbers without using addition operator.

11. Write a c program to subtract two numbers without using subtraction operator.

15. Write a c program to solve quadratic equation.

18. Write a c program which passes structure to function.

28. Write a c program which takes password from user.

29. Write a scanf function in c which accept sentence from user.

30. Write a scanf function in c which accept paragraph from user.

## 15 comments:

what is temp ?

Here temp is any temporary variable to keep the intermediate value.

thanks ! :)

Can't understand this part:

"

for(temp=num;num!=0;num=num/10){

r=num%10;

sum=sum*10+r;

}"

Please elaborate. thanks in advance!

i guess there is a mistake ..it should be

sum= num *10 + r;

program to find palindrome of 010

without using string function

akhilesharya09@gmail.com

thanks!!

Visit 2pforinterview.blogspot.in if anybody want to prepare programming and puzzles for Technical interviews.

plz say program of to print palindromes from 1 to 50

it means that while temp is grater than zero it will run

r=num%10 is done in order to take out the last digit because % gives remainder line if if int num=1234 and int r=1234%10

then r=4 since the initial value of sum is zero therefore for the first time sum will be r that is 4 for the second time it will be 4*10+3 and so on at last it will be 432*10+1 that is 4321

if you have any further problem mail me at letterdrama@gmail.com

no it must not be i have explained it in above question

write a code to determine either the number entered is a palindrome(454,6776)or not?

This is Interview question? solve thisProgram

palindrome can't use loop function???

Can you please tell us in more detail what each variable is ?

It can be solved with less

Variable

Like:

main()

{

int num,ori;

clrscr();

printf(" \n Enter any four digit integer no.:");

scanf("%d", & num);

ori= num;

num=num%10*1000+num/10%10*100+num/10%10*10+num/1000;

if(ori==num)

{

printf("\n no. Is palindrome");

}

else

{

printf("\n no. Is not palindromes");

}

getch();

}

Post a Comment