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
What are the header files used in c language?
List some basic data types in c?
What are the types of data structures in c?
Explain what is gets() function?
What does sizeof int return?
how can I convert a string to a number?
explain what are actual arguments?
What is the best way to comment out a section of code that contains comments?
which of the following shows the correct hierarchy of arithmetic operations in C a) (), **, * or/,+ or - b) (),**,*,/,+,- c) (),**,/,*,+,- d) (),/ or *,- or +
What is printf () in c?
What is the size of a union variable?
When I set a float variable to, say, 3.1, why is printf printing it as 3.0999999?
What are identifiers in c?
What is formal argument?
Explain how are 16- and 32-bit numbers stored?