Write a program to compare two strings without using the
strcmp() function

Answer Posted / anil sai krishna

#include<stdio.h>
main()
{
char a[15],b[15];
int i,l=0,m;
printf("enter the two strings");
scanf("%s%s",a,b);
for(i=0;a[i]=b[i];i++)
{
l++;
}
for(i=0;a[i]!='\0';i++)
{
m++;
}
if(l==m)
{
printf("strings are equal");
}
else
{
printf("not equal");
}
}

Is This Answer Correct ?    7 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is function prototype in c with example?

563


int i[2], j; int *pi;i[0] = 1; i[1] = 5; pi = i; j = *pi + 1 + *(pi + 1)Value of j after execution of the above statements will be a) 7 b) 6 c) 4 d) pointer

641


What is calloc in c?

652


Explain the meaning of keyword 'extern' in a function declaration.

707


What does nil mean in c?

665






main() { inta=10,b=20; a>=5?b=100:b=200; printf("%d ",b); }

899


Explain the red-black trees?

598


What is line in c preprocessor?

604


What is array in c with example?

605


What language is lisp written in?

604


Hai what is the different types of versions and their differences

1479


What is structure data type in c?

558


printf(), scanf() these are a) library functions b) userdefined functions c) system functions d) they are not functions

624


what is the difference between 123 and 0123 in c?

706


What are the different types of data structures in c?

587