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
Explain the difference between #include "..." And #include <...> In c?
What is a stream water?
The number of bytes of storage occupied by short, int and long are a) 2, 2 and 4 b) 2, 4 and 4 c) 4, 4 and 4 d) none
Input is "rama loves rajesh and rajesh Loves rama also and rajesh wear gloves and bloves" To print output is count the numbers of times repeted the word love without case sensitive.
What is a spanning Tree?
What is difference between array and structure in c?
Why we write conio h in c?
What the advantages of using Unions?
Explain the difference between null pointer and void pointer.
Is c dynamically typed?
What is difference between union and structure in c?
What is extern variable in c with example?
What are different types of pointers?
What is calloc in c?
What does static variable mean in c?