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

Explain the difference between ++u and u++?

0 Answers  


Why does notstrcat(string, "!");Work?

0 Answers  


How do I declare an array of N pointers to functions returning pointers to functions returning pointers to characters?

2 Answers  


from which concept of 'c', the static member function of 'c++' has came?

1 Answers   Bosch,


Write a program to swap two numbers without using a temporary variable?

0 Answers   Infosys,






How many levels deep can include files be nested?

0 Answers  


Why do we write return 0 in c?

0 Answers  


Does c have enums?

0 Answers  


Is fortran still used in 2018?

0 Answers  


void main() { int a[]={1,2,3,4,5},i; for(i=0;i<5;i++) printf("%d",a++); getch(); }

3 Answers  


Explain what is the difference between declaring a variable and defining a variable?

1 Answers  


What is difference between constant pointer and constant variable?

0 Answers   Hexaware,


Categories