Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

while initialization of array why we use a[][2] why not a[2][]...?

2322


Is anything faster than c?

975


How can a program be made to print the line number where an error occurs?

1051


Explain what are header files and explain what are its uses in c programming?

1122


How do you do dynamic memory allocation in C applications?

1063


i want to know the procedure of qualcomm for getting a job through offcampus

2425


write a program to find the given number is prime or not

4683


Differentiate between declaring a variable and defining a variable?

1003


Why c is a mother language?

986


Is file a keyword in c?

898


What Is The Difference Between Null And Void Pointer?

1186


What is ambagious result in C? explain with an example.

2567


Why is it that not all header files are declared in every C program?

1163


What are the different types of constants?

1035


What is Dynamic memory allocation in C? Name the dynamic allocation functions.

1354