Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2025 Foundation Course
NEET 2025 Foundation Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
0 votes
305 views
in Structures and Pointers by (29.3k points)
closed by

Write a program to input a string and check whether it is palindrome or not using character pointer.

1 Answer

+1 vote
by (30.3k points)
selected by
 
Best answer

#include <iostream>

using namespace std;

int main()

{

char *str="";

int len,i,j,flag=0;

cout<<"Enter a string";

cin>>str;

for(i=0;*(str+i)!="\0;i++);

len=i;

for(i=0;j=len-1;i<len/2;i++;j--)

{

if(*(str+i)!=*(str+j))

{

flag=1;

break;

}

}

if(flag==1)

cout<<*It is not palindrome";

else

cout<<"It is palindrome";

}

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

...