Bharathiar University
Programming in C++ LabC++ Program 10Write a C++ Program to check whether the given string is a palindrome or not using pointers
In this page
Write a C++ Program to check whether the given string is a palindrome or not using pointers
In this page
- C++ Source Code for MS Dos Turbo C++
Source code for Turbo C++
#include <iostream.h>#include<string.h>#include<conio.h>
int main() { char str[20], rev[20]; int *n; clrscr(); cout<<"Palindrome String Using Pointers"<<endl; cout << "Enter a string: "; cin>>str; strcpy(rev, str); strrev(rev); *n=strcmp(str, rev); if (*n==0) cout<<"String is Palindrome";elsecout<<"String is not Palindrome";getch(); return 0;}
OUTPUT
#include <iostream.h>
#include<string.h>
#include<conio.h>
int main() {
char str[20], rev[20];
int *n;
clrscr();
cout<<"Palindrome String Using Pointers"<<endl;
cout << "Enter a string: ";
cin>>str;
strcpy(rev, str);
strrev(rev);
*n=strcmp(str, rev);
if (*n==0)
cout<<"String is Palindrome";
else
cout<<"String is not Palindrome";
getch();
return 0;
}
No comments:
Post a Comment