Write a program to compare two strings without using the
strcmp() function
Answer Posted / sreevalli kamineni
main()
{
char a[50],b[50];
int i=0,flag;
puts("enter 1st string");
gets(a);
puts("enter 2nd string");
gets(b);
if(strlen(a)!=strlen(b))
puts("not identical");
else
{
while(a[i]!='\0')
{
if(a[i]==b[i])
{
i++;
flag=1;
}
else
{
puts("not identical");
}
}
if(flag==1) puts("identical");
}
| Is This Answer Correct ? | 13 Yes | 3 No |
Post New Answer View All Answers
Why do we use static in c?
What are the types of pointers in c?
Differentiate between declaring a variable and defining a variable?
What is the significance of c program algorithms?
How will you write a code for accessing the length of an array without assigning it to another variable?
How do I round numbers?
How do I convert a string to all upper or lower case?
What do you mean by keywords in c?
Do character constants represent numerical values?
How can I call fortran?
What is the advantage of c?
What is meant by realloc()?
Why is c not oop?
exit () is used to a) exit () terminates the execution of the program itself b) exit () terminates the execution of the loop c) exit () terminates the execution of the block d) none of the above
What is variable and explain rules to declare variable in c?