A simple C++ program that I wrote to ask the user to give a string and then the program will determine whether the given string is a palindrome or not a palindrome and display the results on the screen.
I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details. If you want to advertise on my website kindly contact me also in my email address also. Thank you.
My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.
My mobile number here in the Philippines is 09173084360.
My telephone number at home here in Bacolod City, Negros Occidental Philippines is +63 (034) 4335675.
Here in Bacolod I also accepting computer repair, networking and Arduino Project development at a very affordable price.
Sample Program Output
Program Listing
palindrome.cpp
// palindrome.cpp
// Author : Jake Rodriguez Pomperada,MAED-IT
// Date : October 10, 2019 Thursday 9:57 PM
#include <iostream>
#include <string.h>
using namespace std;
int main() {
char str1[50], str2[50];
int i=0,len=0,j=0, flag=0;
cout <<"\n\n";
cout <<"\tString Palindrome in C++";
cout <<"\n\n";
cout << "\tGive a String : ";
gets(str1);
len = strlen(str1) -1;
for (i=len,j=0; i>=0; i--, j++) {
str2[j] = str1[i];
}
if (strcmp(str1,str2)) {
flag =1;
}
if (flag==1) {
cout <<"\n\n";
cout <<"\t"<<str1 << " is Not a Palindrome";
} else {
cout <<"\n\n";
cout <<"\t"<<str1 << " is a Palindrome";
}
cout <<"\n\n";
cout <<"\tEnd of Program";
}
No comments:
Post a Comment