write a program that uses function strcmp to compare two strings input by user.The program should input the number of characters to be compared. The program should state whether the first string is less than, equal to or greater than the second string
Answers
Answered by
0
Answer:
#include <stdio.h>
#include<string.h>
int main()
{
char str1[100],str2[100];
int num;
printf("Enter the first string :");
scanf("%s",str1);
printf("enter second string :");
scanf("%s",str2);
num=strcmp(str1,str2);
if(num==0)
printf("Both string are equal :");
else if(num>=0)
printf("String %s is greater :",str1);
else
printf("%s is greater :",str2);
}
Explanation: Taking two string and compare it using strcmp .
Put conditions and print the satisfied one.
Thank you .
Similar questions