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
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 |
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 |
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 |
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 |
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 |
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 |
What is the difference between static and global variables?
What is pre-emptive data structure and explain it with example?
Does c have circular shift operators?
print a "hello" word without using printf n puts in c language
two progs are given. one starts counting frm 0 to MAX and the other stars frm MAX to 0. which one executes fast.
how do we remove the printed character in printf statement and write next it it
There are 8 billiard balls, and one of them is slightly heavier, but the only way to tell was by putting it on a weighing scale against another. What's the fewest number of times you'd have to use the scale to find the heavier ball?
Difference between linking and loading?
c language supports bitwise operations, why a) 'c' language is system oriented b) 'c' language is problem oriented c) 'c' language is middle level language d) all the above
what different between c and c++
What is meant by 'bit masking'?
wtite a program that will multiply two integers in recursion function