Learn C ProgrammingLearn ProgrammingPrograms On StringsResources

083. Write a program to accept two strings and compare them in C language

By September 18, 2012 September 5th, 2018 No Comments
#include<stdio.h>
#include<conio.h>  
#include<string.h>
main()
{
	char *s1,*s2;
	clrscr();
	printf("Enter string 1 : ");
	scanf("%s",s1);
	printf("Enter string 2 : ");
	scanf("%s",s2);

	if(strcmp(s1,s2)>0)
		printf("\nString 1 is greater..");
	else if(strcmp(s1,s2)<0)
		printf("\nString 2 is greater..");
	else
		printf("\nStrings are equal..");

	getch();
}


Leave a Reply

DEMO01