C++ Saved Program: gifted-city

facebook share

Here's the online compiler accompanied with IDE at your service. This is a saved code by one of our users. Try it out or save your own from the IDE page and don't forget to leave a feedback. You can find that at the bottom of the page.

//This program takes a string input and checks whether its a palindrome or not
#include <iostream>
#include <string.h>
using namespace std;

int main(){
    char string1[20];
    int i, length;
    int flag = 0;
    cout << "Enter a string: "; cin >> string1;
    length = strlen(string1);
    for(i=0;i < length ;i++){
        if(string1[i] != string1[length-i-1]){
            flag = 1;
    if (flag) {
        cout << string1 << " is not a palindrome" << endl; 
    else {
        cout << string1 << " is a palindrome" << endl; 
    return 0;


Press the execute button or CTRL + enter to run code.