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
If you know then define #pragma?
What is the method to save data in stack data structure type?
What are the advantages of using new operator as compared to the function malloc ()?
What is merge sort in c?
What is use of bit field?
What are categories used for in c?
Not all reserved words are written in lowercase. TRUE or FALSE?
What is the significance of an algorithm to C programming?
What are the different types of C instructions?
What is difference between scanf and gets?
a way in which a pointer stores the address of a pointer which stores the value of the target value a) reference b) allocation c) multiple indirection d) none
Are comments included during the compilation stage and placed in the EXE file as well?
Do you have any idea about the use of "auto" keyword?
What are the types of type specifiers?
What is getch c?