palindrom

 // Online C++ compiler to run C++ program online

#include <iostream>

//#include <bits/stdc++.h>

using namespace std;

int len_str(char arr[]){

    int count=0;

    int i=0;

    while(arr[i]!='\0'){

        count++;

        i++;

    }

    return count;

}

int main() {

    char arr[100]="racecar";

    

    

    int b=len_str(arr);

    bool flag=true;

    for(int i=0;i<=b/2;i++){

        if(arr[i]!=arr[b-1-i]){

            flag=false;

            

        }

        

    }

    if (flag==false){

        cout<<"not palindrome";

    }

    else {

        cout<<"palindrome";

    }

    

}

Comments

Popular posts from this blog

Sum of Even Numbers till N

Find the Runner-Up Score!

Print All Substrings