program for comparing 2 strings without strcmp()

Answer Posted / karthikeyan n p

#include<stdio.h>
#include<conio.h>
void main()
{
char st1[10],st2[10];
int i,sl1=0,sl2;
clrscr();
printf("\nEnter String1:");
scanf("%s",st1);
printf("\nEnter String2:");
scanf("%s",st2);
for(i=0;st1[i]!='\0';i++)
sl1=sl1+1;
for(i=0;st2[i]='\0';i++)
sl2=sl2+1;
if(sl1!=sl2)
{
printf("\nString is not equal.");
}
else
{
for(i=0;st1[i]!='\0' || st2[i]!='\0';i++)
{
if(st1[i]!=st2[i])
{ f=1; }
}
if(f==1)
printf("\nString is not equal.");
else
printf("\nString is equal.");
}
getch();
}

Is This Answer Correct ?    1 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

please explain every phase in the "SDLC" in the dotnet.

2175


What could possibly be the problem if a valid function name such as tolower() is being reported by the C compiler as undefined?

736


WHAT IS THE DEFINATION OF IN TECHNOLOGY AND OFF TECHNOLOGY ?

1853


Wt are the Buses in C Language

2745


can we implement multi-threads in c.

657






What are enums in c?

651


What is the significance of an algorithm to C programming?

590


How to explain the final year project as a fresher please answer with sample project

463


How can a string be converted to a number?

510


How do you print an address?

738


What is hash table in c?

562


When should the volatile modifier be used?

675


#include main() { int *p, *c, i; i = 5; p = (int*) (malloc(sizeof(i))); printf(" %d",*p); *p = 10; printf(" %d %d",i,*p); c = (int*) calloc(2); printf(" %d ",*c); }

620


What does malloc () calloc () realloc () free () do?

554


What is getch () for?

670