Write a program to compare two strings without using the
strcmp() function
Answer Posted / dinesh
#include<stdio.h>
#include<conio.h>
void main()
{
char name1[20],name[20];
int i,j,c=0;
clrscr();
printf("enter two strings");
scanf("%s%s",name1,name);
for(i=0,j=0;name1[i]!='\0'||name[j]!='\0';i++,j++)
{
if(name1[i]!=name[j])
{
c++;
}
}
if(c==0)
printf("equal strings");
else
printf("not equal strings");
}
Is This Answer Correct ? | 10 Yes | 6 No |
Post New Answer View All Answers
What does p mean in physics?
#include show(int t,va_list ptr1) { int a,x,i; a=va_arg(ptr1,int) printf(" %d",a) } display(char) { int x; listptr; va_star(otr,s); n=va_arg(ptr,int); show(x,ptr); } main() { display("hello",4,12,13,14,44); }
why we wont use '&' sing in aceesing the string using scanf
How can I recover the file name given an open stream or file descriptor?
the statement while(i) puts the entire logic in loop. this loop is called a) indefinite loop b) definite loop c) loop syntax wrong d) none of the above
Why calloc is better than malloc?
What are types of preprocessor in c?
What is identifiers in c with examples?
What is c standard library?
Is using exit() the same as using return?
how to build a exercise findig min number of e heap with list imlemented?
Write the test cases for checking a variable having value in range -10.0 to +10.0?
What is c value paradox explain?
Which operators cannot be overloaded a) Sizeof b) .* c) :: d) all of the above
Can you add pointers together? Why would you?