blob: 46eabc92fc332255071c94aa1ee796231e251647 (
plain)
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
|
clear;
clc;
printf("\nExample 2.3\n");
// comparision of 2 strings.
a="hakunah";..........//string 1.
b="matata";.............//string 2.
disp(" a & b respectively are =");
disp(a);
disp(b);
disp("comparing strings");
z=strcmp(a,b);.........//comparision of 2 strings.
if(z==0)
printf("\nMATCHED\n");.......// if strings matched strcmp returns 0.
else
printf("\nNOT MATCHED\n");.........// if string doesn't matched strcmp returns -1.
end
q="akash";
w="akash";
disp("q & w respectively are=");
disp(q);
disp(w);
disp("comparing strings");
x=strcmp(q,w);
if(x==0)
printf("\nMATCHED\n");.......// if strings matched strcmp returns 0.
else
printf("\nNOT MATCHED\n");.........// if string doesn't matched strcmp returns -1.
end
|