Wednesday, July 20, 2011

Program to check whether the two strings are same or not

/*Serial No.59     [swami32.cpp]*/

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
int i,j=0,flag;
char str1[10],str2[10];
clrscr();
printf("Enter the first String==>");
scanf("%s",str1);
printf("Enter the Second String==>");
scanf("%s",str2);
for(i=0;str1[10]!='\0'||str2[j]!='\0';i++,j++)
{
if(str1[i]==str2[j])
flag=1;
break;
}
if(flag==1)
printf("\nBoth Strings %s and %s are same",str1,str2);
else
printf("\nBoth Strings %s and %s are not same",str1,str2);
getch();
}

No comments:

Post a Comment

If you have any doubt, feel free to ask...