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 a constant and types of constants in c?
What does void main return?
Differentiate between declaring a variable and defining a variable?
What is difference between structure and union in c?
What is the basic structure of c?
Explain how do you convert strings to numbers in c?
Why clrscr is used after variable declaration?
What are the advantages and disadvantages of c language?
What is the difference between void main and main in c?
What are the three constants used in c?
What is #include stdlib h?
What is the difference between declaring a variable and defining a variable?
What is nested structure?
What is a ternary operator in c?
What is structure in c definition?