Write a program to compare two strings without using the
strcmp() function
Answer Posted / waqar nawaz
#include<iostream.h>
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int c=0;
char a[10];
char b[10];
gets(a);
gets(b);
for(int i=0,j=0;b[i]!='\0'||a[j]!='\0';i++,j++)
{
if(a[i]!=b[j])
{
c++;
}
}
if(c==0)
cout<<"string match";
else
cout<<"string does not match";
getch();
}
Is This Answer Correct ? | 104 Yes | 51 No |
Post New Answer View All Answers
Explain the difference between ++u and u++?
What are the 5 types of inheritance in c ++?
what is the diffrenet bettwen HTTP and internet protocol
Why is c used in embedded systems?
Why c is faster than c++?
What is I ++ in c programming?
write a c program to calculate sum of digits till it reduces to a single digit using recursion
What are the disadvantages of external storage class?
An expression to whose value an operater is applied a) operand b) variable c) constant d) all of the above
What is the purpose of 'register' keyword in c language?
write a c program to print the next of a particular no without using the arithmetic operator or looping statements?
What does c mean before a date?
Given only putchar (no sprintf, itoa, etc.) write a routine putlong that prints out an unsigned long in decimal. [ I gave the obvious solution of taking % 10 and / 10, which gives us the decimal value in reverse order. This requires an array since we need to print it out in the correct order. The interviewer wasn't too pleased and asked me to give a solution which didn't need the array ].
How do you search data in a data file using random access method?
What is the sizeof () operator?