ALLInterview.com :: Home Page            
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
Google
   
 
Categories >> Software >> Programming Languages >> C
 
 


 

 
 C interview questions  C Interview Questions (2266)
 C++ interview questions  C++ Interview Questions (1121)
 VC++ interview questions  VC++ Interview Questions (342)
 Delphi interview questions  Delphi Interview Questions (510)
 Programming Languages AllOther interview questions  Programming Languages AllOther Interview Questions (652)
Question
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
 Question Submitted By :: C
I also faced this Question!!     Answer Posted By  
 
Answer
# 1
# 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 1 No
Vikas Shukla
 
Answer
# 2
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 ?    0 Yes 0 No
Kifle Tadesse (mekelle Institu
 
 
 
Answer
# 3
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
Kifle Tadesse Mit
 
Answer
# 4
#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
Abdur Rab
 
Answer
# 5
#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
Ankush Kumar Mittal
 
Answer
# 6
#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
Sahibzada Nisar Ahmad
 
Answer
# 7
#include<stdio.h>
main()
{
int n,m;
}
 
Is This Answer Correct ?    7 Yes 43 No
Santhu
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
1.write a program to merge the arrays 2.write efficient code for extracting unique elements from a sorted list of array? Qualcomm 3
program to find a smallest number in an array Microsoft 15
Program to find the value of e raised to power x using while loop N-Tech 5
write a c program that prints all multiples of 3between 1 and 50.   4
Write a function to find the area of a triangle whose length of three sides is given   2
what is the purpose of the code, and is there any problem with it. unsigned int v[10]; unsigned int i = 0; while (i < 10) v[i] = i++; google 2
int *p=20; if u print like dis printf("%d",p); o\p:- 20; how is it possible? plz give me the explanation. Global-Edge 14
whenever a question is posted in a particular category in allinterview.com, Is there any facility to receive an indication mail. For eg: I need to receive an indication email, whenever a question is posted under the category “C Langauage”.   1
Efficient data structure for store/search list of 1000 records a)array b)double linked list c)circular queue d)hash table Value-Labs 2
Why doesn't C have nested functions?   2
what type of errors are checked during compilation   2
Every time i run a c-code in editor, getting some runtime error and editor is disposing, even after reinstalling the software what may be the problem?   2
 
For more C Interview Questions Click Here 
 
 
 
 
 


   
Copyright Policy  |  Terms of Service  |  Articles  |  Site Map  |  RSS Site Map  |  Contact Us
   
Copyright © 2013  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  KalAajKal.com