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
What is function prototype in c with example?
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
What is calloc in c?
Explain the meaning of keyword 'extern' in a function declaration.
What does nil mean in c?
main() { inta=10,b=20; a>=5?b=100:b=200; printf("%d ",b); }
Explain the red-black trees?
What is line in c preprocessor?
What is array in c with example?
What language is lisp written in?
Hai what is the different types of versions and their differences
What is structure data type in c?
printf(), scanf() these are a) library functions b) userdefined functions c) system functions d) they are not functions
what is the difference between 123 and 0123 in c?
What are the different types of data structures in c?