C++-Check if string is a Palindrome or not Using Pointers

C++-Check if string is a Palindrome or not Using Pointers




 

#include<iostream.h>
#include<process.h>
#include<stdio.h>
#include<string.h>
void palindrome(char a[])
{
int l=strlen(a);
char *a1,*b1;
for(a1=a,b1=&a[l-1];a1<=b1;a1++,b1–)
{
if(*a1!=*b1)
{
cout<<”No,it is not a Palindrome:”;
exit(0);
}
}
cout<<”Yes,it is a Palindrome:”;
}
void main()
{
char c[30];
cout<<”Enter the string:”;
gets(c);
cout<<endl;
palindrome(c);
}

Click here for more C++ Programs

info@C++

C++ (pronounced “cee plus plus”).C++ is a general-purpose,powerful programming language.C++ is regarded as an intermediate-level language, as it comprises a combination of both high-level and low-level language features. C++ was Developed by Bjarne Stroustrup starting in 1979.C++ adds OOPS-object oriented features such as classes, and other enhancements to the C programming language.


Rate this post




Further Reading:
http://en.wikipedia.org/wiki/Check
http://en.wikipedia.org/wiki/String
http://en.wikipedia.org/wiki/Palindrome
http://en.wikipedia.org/wiki/Not
http://en.wikipedia.org/wiki/Using

You read About:C++-Check if string is a Palindrome or not Using Pointers

Posted by: Prateek on October 6, 2011


Previous Post: « Next Post: »

© 2017 Trendfy. All rights reserved
Blog Managed by Prateek Jaiswal