#include <iostream> #include <string.h> using namespace std; #define MAX 100 // prototypes/function(s) declaration void input(char line[]); void proc(char line[],char rev_line[]); void check(char line[],char rev_line[]); int main() { system("color f3"); //changing the color of output screen //declaration char line[MAX],rev_line[MAX]; //function(s) calling input(line); proc(line,rev_line); check(line,rev_line); cout<<endl<<endl; system("pause"); return 0; }//end of main() void input(char line[]) { cout<<"Enter line of text, to FINISH press Enter Key : "; cin.getline(line,MAX); }//end of input() void proc(char line[],char rev_line[]) { int n=0, len=strlen(line); for(int i=len-1;i>=0;i--) { rev_line[n]=line[i]; n++; } rev_line[n]='\0';//delimiting the string with NULL Character }//end of proc() void check(char line[],char rev_line[]) { cout<<"\nReverse = "<<rev_line<<endl; if(stricmp(line,rev_line)==0) //stricmp will ignore the case cout<<"\nThis String is a Palindrome.\n"; else cout<<"\nThis string is NOT a Palindrome.\n"; } //end of check
Subscribe to:
Post Comments (Atom)
Post A Comment:
0 comments: