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

Explain about block scope in c?

1088


What is c definition?

1268


Explain output of printf("Hello World"-'A'+'B'); ?

1488


int i[2], j; int *pi;i[0] = 1; i[1] = 5; pi = i; j = *pi + 1 + *(pi + 1)Value of j after execution of the above statements will be a) 7 b) 6 c) 4 d) pointer

1033


Explain how do you sort filenames in a directory?

1032


Explain that why C is procedural?

1134


What are the advantages and disadvantages of pointers?

1067


How can I insert or delete a line (or record) in the middle of a file?

1014


What is putchar() function?

1147


What is the significance of an algorithm to C programming?

1042


.main() { char *p = "hello world!"; p[0] = 'H'; printf("%s",p); }

1289


Are local variables initialized to zero by default in c?

1043


Is there anything like an ifdef for typedefs?

1147


how to build a exercise findig min number of e heap with list imlemented?

2071


What's the total generic pointer type?

1050