Namiss ko magprogram haha. Palindrome program c++. Last activity namin to sa programming this year. 1stt yearr IT feels. Dami pang di naturo namin. Hays. Share ko lanh yung code hehe.

include <iostream>

include <string.h>

using namespace std;

int main() { char str[100],str1[100]; int a,b,c;

cout<<"Enter a word that you want to determine if Palindrome or not:"<<endl;
cin>>str;

strcpy(str1,str);
strrev(str);
b=strlen(str);

for(a=0;a<b;a++)
{
    if(str1[a]==str[a])
    {
        c=1;
    }
    else
    {
        c=0;
    }
}

if(c==1)
{
    cout<<"\n"<<str1<<" is a Palindrome";
}
else
{
    cout<<"\n"<<str1<<" is Not a Palindrome";
}cout<<"\n";

return 0;

}

1
$
User's avatar
@Lira posted 4 years ago

Comments