palindrome for strings and numbers----Can anybody do the
prog?

Answer Posted / shruti

//the palindrome for string can also be written as below,
without using inbuilt functions.

void main()
{
char str[10];
int flag = 0;
int i , j;

puts("ENTER THE STRING");
fflush(stdin);
gets(str);


for(i = 0 ; str[i] != '\0' ; i++);
i--;

for(j = 0 ; j<i ; j++ , i--)
{
if(str[j] == str[i])
flag = 1;
else
{
flag = 0;
break;
}
}

if(flag == 1)
puts("STRING IS A PALINDROME");
else
puts("STRING IS NOT A PALINDROME");
}

Is This Answer Correct ?    4 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How can you call a function, given its name as a string?

716


Write a program for Overriding.

693


Explain what is the benefit of using const for declaring constants?

620


In this problem you are to write a program that will cut some number of prime numbers from the list of prime numbers between 1 and N.Your program will read in a number N; determine the list of prime numbers between 1 and N; and print the C*2 prime numbers from the center of the list if there are an even number of prime numbers or (C*2)-1 prime numbers from the center of the list if there are an odd number of prime numbers in the list.

1386


What is difference between function overloading and operator overloading?

664






Explain about the functions strcat() and strcmp()?

603


stripos — Find position of first occurrence of a case- insensitive string int stripos ( char* haystack, char* needle, int offset ) Returns the numeric position of the first occurrence of needle in the haystack string. Note that the needle may be a string of one or more characters. If needle is not found, stripos() will return -1. The function should not make use of any C library function calls.

1858


What are type modifiers in c?

625


Why dont c comments nest?

625


How can I make sure that my program is the only one accessing a file?

687


GIVEN A FLOATING POINT NUMBER HOW IS IT ACTUALLY STORED IN MEMORY ? CAN ANYONE EXPLAIN?? THE 32 BIT REPRESENTATION OF A FLOATING POINT NUMBER ALLOTS: 1 BIT-SIGN 8 BITS-EXPONENT 23 BITS-MANTISSA

1433


What is time null in c?

587


What is the use of getchar() function?

634


Do you know null pointer?

617


my project name is adulteration of chille powder.how can i explain it to the hr when he asks me about the project?

1126