Write a program to compare two strings without using the
strcmp() function
Answer Posted / nomi mayana
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
char a[25],b[25];
int cnt=1,i=1;
cout<<"\n ENTER THE STRING 1 : ";
cin>>a;
cout<<"\n ENTER THE STRING 2 : ";
cin>>b;
while(a[i]!='\0' && b[i]!='\0')
{
if(a[i]==b[i])
{
cnt++;
}
else
{
cout<<"\n\n THE TWO STRINGS ARE NOT EQUAL";
}
i++;
}
if(i==cnt)
{
int n;
cout<<"\n\t\t~~~~~~~~~~COMPARISON RESULT~~~~~~~~~~~";
cout<<"\n THE GIVEN TWO STRINGS ARE SAME ";
}
//getch();
return 0;
}
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What is c preprocessor mean?
hi send me sample aptitude papers of cts?
What is meant by keywords in c?
Can static variables be declared in a header file?
design and implement a data structure and performs the following operation with the help of file (included 1000 student marks in 5 sub. and %also) 1.how many students are fail in all 5 subjects (if >35) 2. delete all student data those are fail in all 5 subjects. 3. update the grace marks (5 no. if exam paper is 100 marks) 4. arrange the student data in ascending order basis of marks. 5.insert double of deleted students with marks in the list.
If errno contains a nonzero number, is there an error?
what will be the output for the following main() { printf("hi" "hello"); }
What is the use of a semicolon (;) at the end of every program statement?
What does void main () mean?
Do pointers take up memory?
How will you delete a node in DLL?
Why we use break in c?
Is python a c language?
What is the process of writing the null pointer?
Can a pointer be volatile in c?