write program for palindrome

Answers were Sorted based on User's Feedback



write program for palindrome..

Answer / mojib khan

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char str1[30],str2[30];
int l;
clrscr();
printf("Enter the string \t");
gets(str1);
strrev(str1);//for reverse string
strcpy(str1,str2);//copy str1 to str2
l=strcmp(str2,str1); //comparing strings it will return 0/1
if(l==0)
{
printf("\nString is Palindrom");
}
else
printf("String is not palindrom");
getch();
}

Is This Answer Correct ?    1 Yes 0 No

write program for palindrome..

Answer / badsha

#include<iostream.h>
void main()
{
int m=0,n,s=0,r;
cout<<"Enter any number :"<<endl;
cin>>n;
m=n;
while(n>0)
{
r=n%10;
s=s*10+r;
n=n/10;
}
if(m==s)
{
cout<<"it is palindrom :"<<endl;
}
else
{
cout<<"No is Not palindrom :"<<endl;
}
}

Is This Answer Correct ?    1 Yes 0 No

write program for palindrome..

Answer / neha

char a[20],b[20];
printf("enter a string");
scanf("%s",&a);
strcpy(b,a);//copies string a to b
strrev(b);//reverses string b
if(strcmp(a,b)==0)//compares if the original and reverse
strings are same
printf("\n%s is a palindrome",a);
else
printf("\n%s is not a palindrome",a);
return 0;

Is This Answer Correct ?    1 Yes 0 No

write program for palindrome..

Answer / prashant gupta

//Using C# Language

using System;

class Palindrome
{
public void CalculatePalindrome()
{
//int number;
Console.Write("Enter the no to check its
Palindromic property : ");
int number = int.Parse(Console.ReadLine());

int temp = number;
int sum = 0;

while (number > 0)
{

Int32 remainder = number % 10;
number = number / 10;
sum = sum * 10 + remainder;
}

if (sum == temp)
{
Console.WriteLine("The no {0} is
palindrome.", sum);
}

else
{
Console.WriteLine("The no {0} is not a
palindrom no.", sum);
}
}

public static void Main()
{
Palindrome _palindrome = new Palindrome();
_palindrome.CalculatePalindrome();
}
}

Is This Answer Correct ?    1 Yes 0 No

write program for palindrome..

Answer / prashant gupta

//in C Language

#include <stdio.h>
#include <conio.h>

int main()

{
int number,temp,remainder,sum=0;
printf("\n\nEnter no: ");
scanf("%d",&number);
temp = number; //Value of temp stores unmodified n value

while(number>0)
{
remainder=number%10; //Gets Last Digit
number/=10; //Truncates Last Digit
sum=sum*10 + remainder; //Builds value of reversed number
}

if (sum==temp)
printf ("\nThe Number Is A Palindrome ");
else
printf ("\nThe Number Is Not A Palindrome ");

getch ();
return 0;

}

Is This Answer Correct ?    1 Yes 0 No

write program for palindrome..

Answer / amol

#include<stdio.h>
void main()
{
int p,q,r,s=0;
printf("\n Enter the number ::");
scanf("%d",&p);
q=p;
while(p>0)
{
r=p%10;
s=s*10+r;
p=p/10;
}
if(s==q)
{
printf("\n Entered number is palindrome...!!!");
}
else
{
printf("\n Enterde number is NOT a palindrome...!!!");
}
getch();
}

Is This Answer Correct ?    2 Yes 2 No

write program for palindrome..

Answer / ram srikanth

#include<stdio.h>
#include<conio.h>
#include<string.h>
main()
{
char n[50],m[50];
clrscr();
printf("Enter a string");
scanf("%s",n);
strcpy(m,n);
strrev(m);
if (strcpy(n,m)==0) printf("Palindrome");
else printf("not a palindrome");
getch();
}

Is This Answer Correct ?    2 Yes 2 No

write program for palindrome..

Answer / hillol bhattacharya

#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(m==n)
printf("the no is palindrome");
else
printf("no is not palindrome");
getch();
}

Is This Answer Correct ?    0 Yes 0 No

write program for palindrome..

Answer / rupamrox

#include<stdio.h>
#include<conio.h>
main()
{
int n,m,p,rev;
clrscr();
printf("enter a number: ");
scanf("%d",&n);
p=n;
rev=0;
while(n>0)
{
m=n%10;
rev=rev*10+m;
n=n/10;
}
if(rev==p)
printf("%d is palindrome",p);
else
printf("%d is not palindrome",p);
getch();
}

Is This Answer Correct ?    1 Yes 1 No

write program for palindrome..

Answer / madhupriya

#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 ?    1 Yes 1 No

Post New Answer

More C++ General Interview Questions

what is data Abstraction? and give example

147 Answers   Aaditya Info Solutions, American Express, CMS, College School Exams Tests, Data Entry Operator, First Advantage, Google, HCL, IBM, Infosys, Microsoft, Mind Links, NIIT, Oracle, Pact, QBit Systems, TCS, WAYA, Wipro,


Which ide is best for c++?

0 Answers  


What is data binding in c++?

0 Answers  


What is c++ course?

0 Answers  


When there is a global variable and local variable with the same name, how will you access the global variable?

0 Answers  






In which header file does one find isalpha() a) conio.h b) stdio.h c) ctype.h

0 Answers  


Define upcasting.

0 Answers  


What is the use of endl in c++ give an example?

0 Answers  


Under what conditions is multiple inheritance not recommended?

1 Answers  


What is object in c++ wikipedia?

0 Answers  


What is static function and static class?

4 Answers   HCL,


What is abstraction with real time example?

0 Answers  


Categories