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 (2253)
 C++ interview questions  C++ Interview Questions (1111)
 VC++ interview questions  VC++ Interview Questions (342)
 Delphi interview questions  Delphi Interview Questions (510)
 Programming Languages AllOther interview questions  Programming Languages AllOther Interview Questions (646)
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
 
what is the output of the following code? main() { int I; I=0x10+010+10; printf("x=%x",I); } give detailed reason   3
What is structure padding & expalain wid example what is bit wise structure?   1
Write a programe print the sum of series 0,1,2,.....10   7
Which of the following is not an infinite loop ? a.while(1){ .... } b.for(;;){ ... } c.x=0; do{ /*x unaltered within theloop*/ ... }while(x==0); d.# define TRUE 0 ... while(TRUE){ .... } TCS 7
What's the difference between DELETE TABLE and TRUNCATE TABLE commands? CTC 2
write a string copy function routine?   2
#include<stdio.h> main() { char s1[]="Ramco"; char s2[]="Systems"; s1=s2; printf("%s",s1); } Find the output CitiGroup 5
Is there any book to know about Basics of C Language?   3
void main() { int a=1; while(a++<=1) while(a++<=2); } HCL 4
which is the best site or book for learning C...and i need the content for C..how to get the good programming skills....? can plz suggest me....   2
Can you think of a way when a program crashed before reaching main? If yes how?   2
There are 21 people in a room. They have to form groups of 3 people each. How many combinations are possible? Write a C program to print the same. iGate 1
 
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