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 the latest version on c++?

0 Answers  


What are the basics concepts of OOPS?

1 Answers  


Write a program using shift_half( ) function to shift the elements of first half array to second half and vice versa.

0 Answers  


Write a program to interchange 2 variables without using the third one.

0 Answers  


What are friend functions in C++?

0 Answers   BlackRock,






What is the type of 'this' pointer? When does it get created?

0 Answers  


What is format for defining a structure?

0 Answers  


What does the ios::ate argument do?

0 Answers  


Write the program form Armstrong no in c++?

11 Answers   HCL,


Of the numbers 12 23 9 28 which would be at the top of a properly implemented maxheap a) 28 b) 9 c) Any of them could be

0 Answers  


Which software is best for coding?

0 Answers  


Adobe Interview & Adobe Placement Paper

1 Answers   Adobe,


Categories