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 / madiha

“PROGRAM THAT COPMPARE TWO STRINGS”

#include <iostream>
using namespace std;

int mycomp(char str1[],char str2[])
{
int i=0;
while(1)
{
if(str1[i]>str2[i])
return 1;
if(str1[i]<str2[i])
return -1;
else if(str1[i]=='\0'||str2[i]=='\0')
return 0;
i++;
}
}
int main()
{
cout<<mycomp("madiho","madiha");
return 0;
}

OUTPUT
1

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is it acceptable to declare/define a variable in a c header?

1066


What do header files do?

1032


Can include files be nested?

1065


Difference between malloc() and calloc() function?

1145


What is the value of uninitialized variable in c?

986


Why is structure padding done in c?

1086


Given below are three different ways to print the character for ASCII code 88. Which is the correct way1) char c = 88; cout << c << " ";2) cout.put(88);3) cout << char(88) << " "; a) 1 b) 2 c) 3 d) constant

1093


Difference between pass by reference and pass by value?

1104


What are the data types present in c?

1104


In C programming, how do you insert quote characters (‘ and “) into the output screen?

1489


Why #include is used in c language?

1003


What does 3 mean in texting?

1046


What's the best way of making my program efficient?

1046


Explain what is the difference between null and nul?

1092


Where in memory are my variables stored?

1123