//WAP TO COMPARE TWO STRINGS.
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char A[20],b[20];
char ch='y';
int x;
clrscr();
do
{
fflush(stdin);
puts("\nENTER THE STRING:");
gets(A);
puts("\n\nENTERED STRING IS");
puts("\n\n");
puts(A);
fflush(stdin);
puts("\nENTER THE STRING:");
gets(b);
fflush(stdin);
puts("\n\nENTERED STRING IS");
puts("\n\n");
puts(b);
x=strcmp(A,b);
if(x==0)
printf("\n\nTWO STRINGS ARE EQUAL");
else
printf("\n\nTWO STRINGS ARE NOT EQUAL");
printf("\n\nDO YOU WANT TO CONTINUE?");
scanf("%s",&ch);
}while(ch=='y'||ch=='Y');
getch();
}
/*---------------------------------------------------------
OUTPUT
-----------------------------------------------------------
ENTER THE STRING:
ABHISHEK
ENTERED STRING IS
ABHISHEK
ENTER THE STRING:
WADHWA
ENTERED STRING IS
WADHWA
TWO STRINGS ARE NOT EQUAL
DO YOU WANT TO CONTINUE?Y
ENTER THE STRING:
WADHWA
ENTERED STRING IS
WADHWA
ENTER THE STRING:
WADHWA
ENTERED STRING IS
WADHWA
TWO STRINGS ARE EQUAL
DO YOU WANT TO CONTINUE?N
*/
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char A[20],b[20];
char ch='y';
int x;
clrscr();
do
{
fflush(stdin);
puts("\nENTER THE STRING:");
gets(A);
puts("\n\nENTERED STRING IS");
puts("\n\n");
puts(A);
fflush(stdin);
puts("\nENTER THE STRING:");
gets(b);
fflush(stdin);
puts("\n\nENTERED STRING IS");
puts("\n\n");
puts(b);
x=strcmp(A,b);
if(x==0)
printf("\n\nTWO STRINGS ARE EQUAL");
else
printf("\n\nTWO STRINGS ARE NOT EQUAL");
printf("\n\nDO YOU WANT TO CONTINUE?");
scanf("%s",&ch);
}while(ch=='y'||ch=='Y');
getch();
}
/*---------------------------------------------------------
OUTPUT
-----------------------------------------------------------
ENTER THE STRING:
ABHISHEK
ENTERED STRING IS
ABHISHEK
ENTER THE STRING:
WADHWA
ENTERED STRING IS
WADHWA
TWO STRINGS ARE NOT EQUAL
DO YOU WANT TO CONTINUE?Y
ENTER THE STRING:
WADHWA
ENTERED STRING IS
WADHWA
ENTER THE STRING:
WADHWA
ENTERED STRING IS
WADHWA
TWO STRINGS ARE EQUAL
DO YOU WANT TO CONTINUE?N
*/
No comments:
Post a Comment