ALLInterview.com :: Home Page KalAajKal.com
 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                      
tip   To Refer this Site to Your Friends   Click Here
Google
 
Categories  >>  Software  >>  Programming Languages  >>  C
 
 


 

 
 C interview questions  C Interview Questions
 C++ interview questions  C++ Interview Questions
 VC++ interview questions  VC++ Interview Questions
 Delphi interview questions  Delphi Interview Questions
 Programming Languages AllOther interview questions  Programming Languages AllOther Interview Questions
Question
palindrome for strings and numbers----Can anybody do the 
prog?
 Question Submitted By :: Sanglap
I also faced this Question!!     Rank Answer Posted By  
 
  Re: palindrome for strings and numbers----Can anybody do the prog?
Answer
# 1
#include<stdio.h>
#include<conio.h>
void main()
{
 int n,r,temp;
 int s=0;
 clrscr();
 printf("enter the number");
 scanf("%d",&n);
 temp=n;
 while(temp>0)
  {
    r=temp%10;
    s=s*10+r;
    temp=temp/10;
  }
  if(n==temp)
    printf(number is pallindrome");
  else
    printf("not pallindrome");
  getch();
}
 
Is This Answer Correct ?    2 Yes 0 No
Arup Bhattacharya
 
  Re: palindrome for strings and numbers----Can anybody do the prog?
Answer
# 2
/*some corrections to above solution*/
#include<stdio.h>
#include<conio.h>
void main()
{
 int n,r,temp;
 int s=0;
 
 printf("enter the number");
 scanf("%d",&n);
 temp=n;
 while(temp>0)
  {
    r=temp%10;
    s=s*10+r;
    temp=temp/10;
  }
  if(n==s)
    printf("number is pallindrome");
  else
    printf("not pallindrome");
  getch();
}
 
Is This Answer Correct ?    2 Yes 2 No
Subbu
 
 
 
  Re: palindrome for strings and numbers----Can anybody do the prog?
Answer
# 3
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char a[20],b[20];
int i;
clrscr();
printf("\n Enter the Number or String to find Palindrome");
scanf("%s",a);
strcpy(b,a);
strrev(a);
if(strcmp(a,b)==0)
{
printf("\n Entered data is Palindrome\n");
}
else
{
printf("\n Entered data is not a Palindrome\n");
}
getch();
}
 
Is This Answer Correct ?    5 Yes 1 No
Harish
 
  Re: palindrome for strings and numbers----Can anybody do the prog?
Answer
# 4
//the palindrome for string can also be written as below, 
without using inbuilt functions.

void main()
{
char str[10];
int flag = 0;
int i , j;

puts("ENTER THE STRING");
fflush(stdin);
gets(str);


for(i = 0 ; str[i] != '\0' ; i++);
i--;

for(j = 0 ; j<i ; j++ , i--)
{
  if(str[j] == str[i])
    flag = 1;
  else
  {
     flag = 0;
     break;
  }
}

if(flag == 1)
  puts("STRING IS A PALINDROME");
else
  puts("STRING IS NOT A PALINDROME");
}
 
Is This Answer Correct ?    1 Yes 1 No
Shruti
 
  Re: palindrome for strings and numbers----Can anybody do the prog?
Answer
# 5
#include<stdio.h>
void main
{
int n,t,d,r;
printf("Enter the number:");
scanf("%d",&n);
t=n;
while(n>=1)
{
d=n%10;
r=(r*10)+d;
n=n/10;
}
if(t==r)
printf("Palindrome");
else
printf("Not a palindrome");
}
 
Is This Answer Correct ?    1 Yes 0 No
Sree
 
  Re: palindrome for strings and numbers----Can anybody do the prog?
Answer
# 6
#include<stdio.h>
int main()
{
 int n,sum=0,temp;
 printf("Enter nuber\n");
 scanf("%d",&n);
 temp = n;
 while(n>1)
 {
   n = n%10;
   sum = n + sum*10;
   n = n / 10;
 }
 if(temp == sum)
    printf("Given number is polindram\n");
 else
    printf("Given number is not polindram\n");

}
 
Is This Answer Correct ?    0 Yes 2 No
Dally
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
Is it possible to create recycle bin in mobiles?  2
write a program that print itself even if the source file is deleted?  1
const char * char * const What is the differnce between the above tow?. TCS5
11. Look at the Code: #include<string.h> void main() { char s1[]="abcd"; char s2[10]; char s3[]="efgh"; int i; clrscr(); i=strcmp(strcat(s3,ctrcpy(s2,s1))strcat(s3,"abcd")); printf("%d",i); } What will be the output? A)No output B) A Non Integer C)0 D) Garbage Accenture7
Evaluate the following: int fn(int v) { if(v==1 || v==0) return 1; if(v%2==0) return fn(v/2)+2; else return fn(v-1)+3; } for fn(7); 1) 10 2) 11 3) 1  6
9.how do you write a function that takes a variable number of arguments? What is the prototype of printf () function? 10.How do you access command-line arguments? 11.what does ‘#include<stdio.h>’ mean? 12.what is the difference between #include<> and #include”…”? 13.what are # pragma staments? 14.what is the most appropriate way to write a multi-statement macro? L&T4
what is the difference between malloc() and calloc() function?  1
what information does the header files contain? BSNL5
Which of the following are valid "include" formats? A)#include and #include[file.h] B)#include (file.h) and #include C)#include [file.h] and #include "file.h" D)#include <file.h> and #include "file.h" Accenture14
Write a program to remove the C comments(/* */) and C++ comments(//) from a file. The file should be declared in command line. Subex2
find second largest element in array w/o using sorting techniques? use onle one for loop. Zycus-Infotech2
What's wrong with the call "fopen ("c:\newdir\file.dat", "r")"?  1
what is the output of below pgm? void main() { int i=0; if(i) printf("pass"); else printf("fail"); }  3
AMMONG THE 4 STROAGE CLASSES IN C, WHICH ONE FASTEST? HCL12
How can I set an array's size at run time?  7
without a terminator how can we print a message in a printf () function. NIIT5
I have a function which accepts a pointer to an int. How can I pass a constant like 5 to it?  3
main() { int x=20,y=35; x = y++ + x++; y = ++y + ++x; printf("%d %d\n",x,y); } what is the output? Ramco4
explain memory layout of a C program  1
what are brk, sbrk? Oracle1
 
For more C Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com