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 is return in c programming?
C program execution always begins with a) #include b) comment (/*-------*/) c) main() d) declaration instructions
What are the application of void data type in c?
Why is it usually a bad idea to use gets()? Suggest a workaround.
Hi how many types of software editions are there and their difference (like home editions, enterprise, standard etc) can u please help me
What is hashing in c language?
List the difference between a "copy constructor" and a "assignment operator"?
How many types of sorting are there in c?
What is pointer in c?
Is r written in c?
What is main () in c?
Can the sizeof operator be used to tell the size of an array passed to a function?
What are the modifiers available in c programming language?
Do string constants represent numerical values?
What is realloc in c?