forked from iamAnki/Codes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStringConcatenation.cpp
More file actions
68 lines (61 loc) · 1007 Bytes
/
StringConcatenation.cpp
File metadata and controls
68 lines (61 loc) · 1007 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include<stdio.h>
#include<string.h>
int main ()
{
char stra[100], strb[100], strc[100];
int i=0, j=0, k=0;
printf("Enter the first string:");
gets(stra);
printf("\n First string is:");
puts(stra);
printf("\n Enter the second string:");
gets(strb);
printf("\n second string is:");
puts(strb);
int la, lb, count=1;
char a[5];
la=strlen(stra);
lb=strlen(strb);
if(la==lb)
{
while(stra[i]!='\0')
{
if(stra[i]==strb[i])
{
a[j]=stra[i];
i++;
j++;
}
else
{
printf("\n The string is equal upto length %d",i);
printf("\n The string is not equal!!!");
printf("\n");
putchar(stra[i]);
printf(" with compare to ");
putchar(strb[i]);
i++;
count=0;
}
//k++;
}
}
if(count==1)
printf("\n The string is equal!!!");
else
{
printf("\nThe charaters are equal are:");
for(k=0;k<=j;k++)
printf("%c", a[k]);
}
if(la!=lb)
{
if(stra[i]>strb[i])
printf("\n The stringa is greater than stringb!!!");
else if(stra[i]<strb[i])
{
printf("\n String a is less than string b");
}
}
return 0;
}