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 difference between Structure and Unions?
Why we use void main in c?
What is sizeof array?
What is a void * in c?
write a c program for swapping two strings using pointer
What does c value mean?
What is an lvalue?
Is it valid to address one element beyond the end of an array?
What is time complexity c?
What tq means in chat?
write a C program: To recognize date of any format even formats like "feb-02-2003","02-february-2003",mm/dd/yy, dd/mm/yy and display it as mm/dd/yy.
What is the difference between printf and scanf in c?
What are the header files used in c language?
What is the use of volatile?
Write a program to check palindrome number in c programming?