File tree Expand file tree Collapse file tree 1 file changed +51
-0
lines changed Expand file tree Collapse file tree 1 file changed +51
-0
lines changed Original file line number Diff line number Diff line change 1+ #include <stdio.h>
2+ int length (char * s )
3+ {
4+ int i = 0 ;
5+ while (* (s + i )!= '\0' )
6+ {
7+ i ++ ;
8+ }
9+ return i ;
10+ }
11+ int compare (char * s ,char * s1 ,int len )
12+ {
13+ int i ,ascii = 0 ,ascii_ = 0 ;
14+ for (i = 0 ;i < len ;i ++ )
15+ {
16+ if (* (s + i )!= * (s1 + i ))
17+ {
18+ ascii = ascii + (int )* (s + i );
19+ ascii_ = ascii_ + (int )* (s1 + i );
20+ }
21+ }
22+ ascii = ascii - ascii_ ;
23+ return ascii ;
24+ }
25+ void main ()
26+ {
27+ char s [100 ],s1 [100 ];
28+ int len ,len1 ,comp ;
29+ puts ("Enter the 1st string " );
30+ gets (s );
31+ puts ("Enter the 2nd string " );
32+ gets (s1 );
33+ len = length (s );
34+ len1 = length (s1 );
35+ if (len == len1 )
36+ {
37+ comp = compare (s ,s1 ,len );
38+ if (comp == 0 )
39+ {
40+ puts ("Two strings are equal." );
41+ }
42+ else
43+ {
44+ puts ("Two strings are not equal." );
45+ }
46+ }
47+ else
48+ {
49+ puts ("Two strings are not equal." );
50+ }
51+ }
You can’t perform that action at this time.
0 commit comments