x

Choose Country Code

x

Direction

x

Ask a Question

  • Ask a Question
  • Scan a Question
  • Post MCQ
  • Note: File extension must be of jpg, jpeg, png, bmp format and file size must not exceed 5 MB
x

Ask a Question

x

x
x
x
Hire a Tutor

Answers and Solutions

What's Your Question?
Answer

#include<stdio.h>

#include<conio.h>

 

void main() {

char str[50], ispal='t';

int len=0, i, j;

clrscr();

 

printf("Enter a string: ");

fflush(stdin);

gets(str);

 

while(str[len])

len++;

 

for(i=0, j=(len-1) ; i<(len/2) ; i++, j--) {

if(str[i] != str[j])

{

ispal = 'f';

break;

}

}

 

if(ispal == 't')

printf("\nPALINDROME.");

else

printf("\nNOT PALINDROME.");

 

getch();

}

Answer

#include <stdio.h>

#include <string.h>

int main()

{

char string1[20];

int i, length;

int flag = 0;

printf("Enter a string:");

scanf("%s", string1);

length = strlen(string1);

for(i=0;i < length ;i++)

{

if(string1[i] != string1[length-i-1])

{

flag = 1; break;

}

}

if (flag)

{

printf("%s is not a palindrome", string1);

}

else

{

printf("%s is a palindrome", string1);

}

return 0;

}

Post Answer and Earn Credit Points

Get 5 credit points for each correct answer. The best one gets 25 in all.

Post Answer