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 functions are used for dynamic memory allocation in c language?
What is difference between function overloading and operator overloading?
What is scanf_s in c?
what is ur strangth & weekness
Why doesn't C support function overloading?
can any one provide me the notes of data structure for ignou cs-62 paper
Where we use clrscr in c?
#define PRINT(int) printf("int = %d ",int) main() {< BR> intx,y,z; x=03;y=02;z=01; PRINT(x^x); z<<=3;PRINT(x); y>>=3;PRINT(y); }
A function can make the value of a variable available to another by a) declaring the variable as global variable b) Passing the variable as a parameter to the second function c) Either of the two methods in (A) and (B) d) binary stream
Is c a great language, or what?
code for quick sort?
What is the difference between far and near ?
What is difference between static and global variable in c?
What is the use of sizeof?
Explain the concept and use of type void.