Write a program to compare two strings without using the
strcmp() function
Answer Posted / bharat prajapati
#include <stdio.h>
#include <string.h>
main()
{
char s1[10],s2[10];
int i,j;
clrscr();
printf("\nEnter first String:");
scanf("%s",s1);
printf("\nEnter second String:");
scanf("%s",s2);
for(i=0;s1[i]!='\0';i++)
{
for(j=0;s2[j]!='\0';j++)
{
if(s1[i] == s2[j])
continue;
}
}
if (i==j)
{
printf("String s1 : %s and s2 : %s are EQUAL \n",s1,s2);
}
else
printf("String s1 : %s and s2 : %s are NOT EQUAL
\n",s1,s2);
getch();
}
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
explain what is a newline escape sequence?
why use functions a) writing functions avoids rewriting the same code over and over b) using functions it becomes easier to write programs and keep track of what they are doing c) a & b d) none of the above
Is it possible to use curly brackets ({}) to enclose single line code in c program?
how many errors in c explain deply
What is the right type to use for boolean values in c? Is there a standard type? Should I use #defines or enums for the true and false values?
Explain what are the different file extensions involved when programming in c?
Why is c used in embedded systems?
What are preprocessor directives in c?
Are local variables initialized to zero by default in c?
What is the use of in c?
How can I ensure that integer arithmetic doesnt overflow?
How many data structures are there in c?
why programs in c are running with out #include
What is the difference between fread buffer() and fwrite buffer()?
Explain that why C is procedural?