Skip to content

Commit 831a55b

Browse files
authored
Task14-Compare Two Strings .c
1 parent d2786c5 commit 831a55b

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

Task14-Compare Two Strings .c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#include <stdio.h>
2+
#include <string.h>
3+
int main(){
4+
char Str1[100], Str2[100];
5+
int result, i;
6+
printf("1st String = ");
7+
gets(Str1);
8+
printf("2nd string = ");
9+
gets(Str2);
10+
for(i = 0; Str1[i] == Str2[i] && Str1[i] == '\0'; i++);
11+
if(Str1[i] < Str2[i])
12+
{
13+
printf("str1 is less than str2");
14+
}
15+
else if(Str1[i] > Str2[i])
16+
{
17+
printf("str2 is less than str1");
18+
}
19+
else
20+
{
21+
printf("str1 is equal to str2");
22+
}
23+
return 0;
24+
}

0 commit comments

Comments
 (0)