Write a program to compare two strings without using the
strcmp() function
Answer Posted / navy
#include<stdio.h>
#include<conio.h>
void main()
{
char s1[20];
int i, j, len=0, flag=0;
printf("\nEnter any string: ");
gets(s1);
for (i=0; s1[i]!='\0'; i++)
len++;
i = 0;
j = len-1;
while (i < len)
{
if (s1[i] != s1[j])
{
flag = 1;
break;
}
i++;
j--;
}
if (flag == 0)
printf("\nString is palindrome");
else
printf("\nString is not palindrome");
getch();
}
| Is This Answer Correct ? | 4 Yes | 1 No |
Post New Answer View All Answers
Why is C language being considered a middle level language?
What is type qualifiers?
What is sizeof int?
Is c object oriented?
Without Computer networks, Computers will be half the use. Comment.
Differentiate between calloc and malloc.
What do the functions atoi(), itoa() and gcvt() do?
What is scanf_s in c?
What is a structure and why it is used?
Can we declare variables anywhere in c?
What is a constant and types of constants in c?
What does == mean in texting?
What is the difference between int main and void main in c?
Can i use “int” data type to store the value 32768? Why?
Explain how can you tell whether a program was compiled using c versus c++?