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
what value is returned to operating system after program execution?
What is the advantage of c?
a direct address that identifies a location by means of its displacement from a base address or segment a) absolute address b) relative address c) relative mode d) absolute mode
What is advantage of pointer in c?
When should the volatile modifier be used?
What is a pointer in c?
I came across some code that puts a (void) cast before each call to printf. Why?
What is the value of c?
void main(int n) { if(n==0) return; main(--n); printf("%d ",n); getch(); } how it work and what will be its output...............it any one know ans plz reply
What the different types of arrays in c?
Why static variable is used in c?
Can we declare a function inside a function in c?
What is c programing language?
a parameter passed between a calling program and a called program a) variable b) constant c) argument d) all of the above
c language supports bitwise operations, why a) 'c' language is system oriented b) 'c' language is problem oriented c) 'c' language is middle level language d) all the above