Write a program to compare two strings without using the
strcmp() function
Answer Posted / belsia
void main()
{
char a[10],b[10];
int i=0;
scanf("%s%s",a,b);
if(strlen(a)!=strlen(b))
printf("they are different strings");
else
{
while(a[i]!='\0')
{
if(a[i]==b[i])
i++;
else
{
printf("They are different strings");
exit(0);
}
}
printf("Both are same");
}
getch();
}
Is This Answer Correct ? | 10 Yes | 13 No |
Post New Answer View All Answers
What are the data types present in c?
Write a program to print ASCII code for a given digit.
What is LINKED LIST? How can you access the last element in a linked list?
What are the Advantages of using macro
What is switch in c?
A variable that is defined in a specified portion of a program but can be used throughout the program a) global variable b) local variable c) character d) none
What is a spanning Tree?
Should a function contain a return statement if it does not return a value?
What 'lex' does?
Write a program in "C" to calculate the root of a quadratic equation ax^2+bx+c=0, where the value of a,b & c are known.
For what purpose null pointer used?
What is an lvalue?
What is the size of array float a(10)?
What is difference between arrays and pointers?
write a program to copy the string using switch case?