write program for palindrome
Answers were Sorted based on User's Feedback
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 |
#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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
Explain the extern storage classes in c++.
Can we use this pointer in a class specific, operator-overloading function for new operator?
What is a protocol class?
Define a constructor - what it is and how it might be called (2 methods)?
this is to swap to strings....but in output the whole strings are swapped leaving first as it is...why it is so #include<iostream.h> int main() { char a[]="ajeet"; char b[]="singh"; long x=*a; long y=*b; cout<<x<<":"<<y; x=x+y; y=x-y; x=x-y; *a=x; *b=y; cout<<x<<":"<<y; cout<<&a<<endl; cout<<&b<<endl; }
how to explain our contribution in the project?
How much maximum can you allocate in a single call to malloc()?
How long will it take to learn programming?
How much is size of struct having 1 char & 1 integer?
The "virtual" specifier in a member function enables which one of the following? a) Monmorphism b) Late binding c) Metamorphism d) Solomorphism e) Inheritance
What are the differences between public, private, and protected access?
12 Answers IBM, Oracle, Wipro,
Which function should be used to free the memory allocated by calloc()?