Skip to content

Commit 9b4cb87

Browse files
committed
using pointer find the identical elements c-basics
1 parent b430900 commit 9b4cb87

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

pointerfunarrayidentical.c

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#include<stdio.h>
2+
void main()
3+
{
4+
int a[50],b[50],*p,*q,n,m,i;
5+
printf("Enter number of array 1");
6+
scanf("%d",&n);
7+
printf("Enter the elements");
8+
for(i=0;i<n;i++)
9+
{
10+
scanf("%d",&a[i]);
11+
}
12+
printf("Enter number of array 2");
13+
scanf("%d",&m);
14+
printf("Enter the elements");
15+
for(i=0;i<m;i++)
16+
{
17+
scanf("%d",&b[i]);
18+
}
19+
p=a;
20+
q=b;
21+
if(n==m)
22+
{
23+
iden(p,q,n);
24+
}
25+
else
26+
{
27+
printf("0");
28+
}
29+
30+
}
31+
void iden(int *p,int *q,int n)
32+
{
33+
int i,z=0;
34+
for(i=0;i<n;i++)
35+
{
36+
if(*(p+i)==*(q+i))
37+
{
38+
z++;
39+
}
40+
else
41+
{
42+
z=0;
43+
break;
44+
}
45+
}
46+
if(z==0)
47+
{
48+
printf("0");
49+
}
50+
else
51+
{
52+
printf("1");
53+
}
54+
}

0 commit comments

Comments
 (0)