Print all the palindrome numbers.If a number is not
palindrome make it one by attaching the reverse to it.
eg:123
output:123321 (or) 12321

Answers were Sorted based on User's Feedback



Print all the palindrome numbers.If a number is not palindrome make it one by attaching the reverse..

Answer / vikas shukla

# include<stdio.h>
int main()
{
int n,n1,rem,rev=0;
printf("enter the number\n");
scanf("%d",&n);
n1=n;
while(n>0)
{
rem=n%10;
rev=rev*10+rem;
n=n/10;
}
if(n1==rev)
{
prinntf("the given no is palindrome");
}
else
{
printf("no is not palindrome");
}return 0;
}

Is This Answer Correct ?    4 Yes 2 No

Print all the palindrome numbers.If a number is not palindrome make it one by attaching the reverse..

Answer / kifle tadesse (mekelle institu

1.# include<stdio.h>
2. int main()
3. {
4. int n,n1,rem,rev=0;
5. printf("enter the number u want to reverse\n");
6. scanf("%d",&n);
7.n1=n;
8. while(n>0)
9.{
10. rem=n%10;
11. rev=rev*10+rem;
12. n=n/10;
13. }
14. if(n1==rev)
15. printf("the given no is palindrome");
16. else
17. {
18. printf("no is not palindrome\n");
19. printf(" its palindrome by attaching it's reverse is
%d%d\n",n1,rev);
20. }return 0;
21. }

Is This Answer Correct ?    2 Yes 0 No

Print all the palindrome numbers.If a number is not palindrome make it one by attaching the reverse..

Answer / kifle tadesse mit

1# include<stdio.h>
2 int main()
3 {
4 int n,n1,rem,rev=0;
5 printf("enter the number u want to reverse\n");
6 scanf("%d",&n);
7n1=n;
8 while(n>0)
9{
10 rem=n%10;
11 rev=rev*10+rem;
12 n=n/10;
13 }
14 if(n1==rev)
15 printf("the given no is palindrome");
16 else
17 {
18 printf("no is not palindrome\n");
19 printf(" its palindrome by attaching it's reverse is
%d%d\n",n1,rev);
20 }return 0;
21 }

Is This Answer Correct ?    0 Yes 0 No

Print all the palindrome numbers.If a number is not palindrome make it one by attaching the reverse..

Answer / abdur rab

#include <stdio.h>

int reverse_digits ( int number, int* digits )
{
int n_digits = 0;
int rev_number = 0;

while ( number ) {
rev_number *= 10;
rev_number += number % 10;
number /= 10;
n_digits++;
}

*( digits ) = n_digits;
return ( rev_number );
}

int palindrome ( int number, int digits )
{
int flag = 1;

while ( number ) {
if ( ( number % 10 ) != ( number / (int)
pow ( 10, digits - 1 ) ) && ( digits > 1 ) ) {
flag = 0;
break;
}

// removing first and last digits
if ( 1 < ( digits -= 2 ) ) {
number /= 10;
number = number % (int) pow ( 10,
digits );
} else break;
}

return ( flag );
}

int main ( int argc, char* argv [] )
{
int number = 123;
int digits = 0;

int rev_number = 0;

rev_number = reverse_digits ( number, &digits );

if ( !palindrome ( number, digits ) ) {
printf ("\n NOT Palindrome, creating
Palindrome");
/**
* if you need 12321 use digits - 1
* if you need 123321 use digits
*/
number *= (int) pow ( 10, ( digits - 1 ) );
number += rev_number % (int) pow ( 10, (
digits - 1 ) );
}

printf ( "\n The Number: %d", number );

return ( 0 );
}

Is This Answer Correct ?    8 Yes 12 No

Print all the palindrome numbers.If a number is not palindrome make it one by attaching the reverse..

Answer / ankush kumar mittal

#include<stdio.h>
void main()
{
int rev=0,a,b,c;
scanf("%d",a);
if(a=!0)
{
b=a%10;
a=a/10;
rev=rev*10+b;
}
}

Is This Answer Correct ?    0 Yes 4 No

Print all the palindrome numbers.If a number is not palindrome make it one by attaching the reverse..

Answer / sahibzada nisar ahmad

#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int a,b,c,d,e;
printf("Enter Three Digits Number=");
scanf("%d",&a);
b=a/100;
c=a%100;
d=c/10;
e=c%10;
printf("\n\tThe Reverse Number is =%d%d%d=",e,d,b);
getch();
}

Is This Answer Correct ?    6 Yes 13 No

Print all the palindrome numbers.If a number is not palindrome make it one by attaching the reverse..

Answer / santhu

#include<stdio.h>
main()
{
int n,m;
}

Is This Answer Correct ?    7 Yes 43 No

Post New Answer

More C Interview Questions

How to convert a binary number to Hexa decimal number?? (Note:Do not convert it into binary and to Hexadecimal)

1 Answers   iLantus, Subex,


What is typedef?

1 Answers  


What is ambagious result in C? explain with an example.

0 Answers   Infosys,


What is getch c?

0 Answers  


1.what are local and global variables? 2.what is the scope of static variables? 3.what is the difference between static and global variables? 4.what are volatile variables? 5.what is the use of 'auto' keyword? 6.how do we make a global variable accessible across files? Explain the extern keyword? 7.what is a function prototype? 8.what does keyword 'extern' mean in a function declaration?

2 Answers   nvidia,






What is data types?

0 Answers  


WRITE A PROGRAM TO PRINT THE FOLLOWING OUTPUTS USING FOR LOOPS. A) * B) ***** *** * * ***** * * *****

2 Answers  


wap to print "hello world" without using the main function.

22 Answers   TCS, Wipro,


What is difference between && and & in c?

0 Answers  


What is the advantage of an array over individual variables?

0 Answers  


A routine usually part of the operation system that loads a program into memory prior to execution a) linker b) loader c) preprocessor d) compiler

0 Answers  


write a c program to find largest of three numbers using simple if only for one time.

1 Answers  


Categories