write program for palindrome

Answers were Sorted based on User's Feedback



write program for palindrome..

Answer / md.irfan(rourkela)

#include<stdio.h>
#include<conio.h>
void main()
{
int n,s=0,m;
clrscr();
printf("enter any no");
scanf("%d",&n);
m=n;
while(n>0)
{
r=n%10;
s=s*10+r;
n=n/10;
}
if(m==n)
printf("the no is palindrome");
else
printf("no is not palindrome");
getch();
}

Is This Answer Correct ?    1204 Yes 747 No

write program for palindrome..

Answer / pallavi attarde

#include<iostream.h>
#include<string.h>

int main()
{
char str[25],str1[25];
cout<<"Enter a string: ";

gets(str);

strcpy(str1,str);
strrev(str);
if(strcmp(str,str1)!=0)
{
cout<<"string is not palindrome";
}
else
{
cout<<"string is a palindrome";
}

cout<<endl;

Is This Answer Correct ?    596 Yes 248 No

write program for palindrome..

Answer / dinakar

#include<stdio.h>
#include<conio.h>
void main()
{
int n,s=0,m;
clrscr();
printf("enter any no");
scanf("%d",&n);
m=n;
while(n>0)
{
r=n%10;
s=s*10+r;
n=n/10;
}
if(s == m) // This is important step
printf("the no is palindrome");
else
printf("no is not palindrome");
getch();
}

Is This Answer Correct ?    242 Yes 88 No

write program for palindrome..

Answer / easwar

#include<stdio.h>
#include<conio.h>
void main()
{
int n,s=0,m,r;
clrscr();
printf("enter any no");
scanf("%d",&n);
m=n;
while(n>0)
{
r=n%10;
s=s*10+r;
n=n/10;
}
if(s == m) // This is important step
printf("the no is palindrome");
else
printf("no is not palindrome");
getch();
}

Is This Answer Correct ?    172 Yes 77 No

write program for palindrome..

Answer / felix

#include<stdio.h>
#include<string.h>
#define size 26
void main()
{
char strsrc[size];
char strtmp[size];
clrscr();
printf("\n Enter String:= ");
gets(strsrc);
strcpy(strtmp,strsrc);
strrev(strtmp);
if(strcmp(strsrc,strtmp)==0)
printf("\n Entered string \"%s\" ispalindrome",strsrc);
else
printf("\n Entered string \"%s\" is not
palindrome",strsrc);
getch();
}

Is This Answer Correct ?    182 Yes 97 No

write program for palindrome..

Answer / dude

#include<stdio.h>
#include<conio.h>
void main()
{
int n,s=0,m;
clrscr();
printf("enter any no");
scanf("%d",&n);
m=n;
while(n>0)
{
r=n%10;
s=s*10+r;
n=n/10;
}
if(s == n) // This is important step
printf("the no is palindrome");
else
printf("no is not palindrome");
getch();
}

Is This Answer Correct ?    199 Yes 137 No

write program for palindrome..

Answer / felix

#include<stdio.h>
#include<ctype.h>
#include<string.h>

int isPalindrome( char *s );

int main ( void )
{
int i = 0;
int ch;
char s[100];

while ((ch = getchar()) != '\n') {
if (isalpha(ch)) {
s[i] = ch;
i++;
}
}

if ( isPalindrome(s) == 1) {
printf("Yes, is a palindrome.\n");
} else {
printf("No, not a palindrome.\n");
}

return 0;

}

int isPalindrome( char *s )
{
int i = strlen(s)-1;
int j = 0;

while (j<=i) {
if(s[j] != s[i]) {
return 0;
}
i--;
j++;
}
return 1;
}

Is This Answer Correct ?    114 Yes 85 No

write program for palindrome..

Answer / aravindhan.d

// r=reminder,s=sum,n=number.
#include<stdio.h>
#include<conio.h>
void main()
{
int n,m,r,s=0;
clrscr();
printf("Enter the n value:");
scanf("%d",&n);
m=n;
while(n>0)
{
r=n%10;
s=s*10+r;
n=n/10;
}
if(m==s)//THIS SAME CODE IS GIVEN ABOVE BUT ONE CHANGE NOT m==n THAT IS m==s
{
printf("NUMBER IS PALINDROME");
}
else
{
printf("NUMBER IS NOT PALINDROME");
}

Is This Answer Correct ?    19 Yes 9 No

write program for palindrome..

Answer / faiz misbah

#include <stdio.h>
#include <stdlib.h>
int main ()
{
int i,j,f=0;
char a[10];
clrscr (); // only works on windows
gets(a);
for (i=0;a[i]!='\0';i++)
{
}
i--;
for (j=0;a[j]!='\0';j++,i--)
{
if (a[i]!=a[j])
{
printf("string is not palindrome");
return(0);
}
}

printf("string is palindrome");
return(0);
}

Is This Answer Correct ?    91 Yes 84 No

write program for palindrome..

Answer / shah

#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<stdio.h>
void main()
{
clrscr();
char str[30],str1[30];
cout<<"ENTER THE WORD:";
gets(str);
strcpy(str1,str);
strrev(str);
if(strcmp(str,str1)==0)
cout<<"THE WORD IS PALINDROME";
else
cout<<"THE WORD IS NOT PALINDROME";
getch();
}

Is This Answer Correct ?    24 Yes 18 No

Post New Answer

More C++ General Interview Questions

How do we balance an AVL Tree in C++?

0 Answers   Impetus,


Are c and c++ different?

0 Answers  


What is near, far and huge pointers? How many bytes are occupied by them?

0 Answers  


Why can you not make a constructor as const?

3 Answers  


Do you know the problem with overriding functions?

0 Answers  






Is c++ free?

0 Answers  


How to create a reference variable in C++

1 Answers  


What apps are written in c++?

0 Answers  


Can you use the function fprintf() to display the output on the screen?

0 Answers  


What is istream c++?

0 Answers  


What does the ios::ate argument do?

0 Answers  


What is problem with overriding functions?

0 Answers  


Categories