/*
program to compare two strings....
*/
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
void main()
{
clrscr();
char a[50],b[50];
int i,j,k=0;
cout<<"Enter the first string:"<<endl;
gets(a);
cout<<"Enter the second string:"<<endl;
gets(b);
if(strlen (a)!=strlen (b))
cout<<"Strings are not equal."<<endl;
else
{
for(i=0,j=0;a[i]!='\0';i++,j++)
{
if(a[i]==b[j])
continue;
else
k=1;
break;
}
if(k>0)
cout<<"Strings are not equal."<<endl;
else
cout<<"Strings are equal."<<endl;
}
getch();
}
program to compare two strings....
*/
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
void main()
{
clrscr();
char a[50],b[50];
int i,j,k=0;
cout<<"Enter the first string:"<<endl;
gets(a);
cout<<"Enter the second string:"<<endl;
gets(b);
if(strlen (a)!=strlen (b))
cout<<"Strings are not equal."<<endl;
else
{
for(i=0,j=0;a[i]!='\0';i++,j++)
{
if(a[i]==b[j])
continue;
else
k=1;
break;
}
if(k>0)
cout<<"Strings are not equal."<<endl;
else
cout<<"Strings are equal."<<endl;
}
getch();
}
0 comments:
Post a Comment