-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathc61.c
More file actions
36 lines (35 loc) · 780 Bytes
/
c61.c
File metadata and controls
36 lines (35 loc) · 780 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
#include<stdio.h>
//check two arrays are equal or not using pointers
int main()
{
int n;
printf("enter sizeof 1st array:");
scanf("%d",&n);
int m;
printf("enter sizeof 2nd array:");
scanf("%d",&m);
int a[n],b[m],*p1=a,*p2=b,flag=0;
if(sizeof(a)!=sizeof(b))
printf("array not equal");
else if(n==m)
{
printf("enter first array elements:");
for(int i=0;i<n;i++)
scanf("%d",&a[i]);
printf("enter 2nd array elements:");
for(int i=0;i<m;i++)
scanf("%d",&b[i]);
for(int i=0;i<n;i++)
{
if(*p1!=*p2){
flag=1;
break;}
p1++;
p2++;
}
if(flag==1)
printf("array not equal");
else
printf("array is equal");
}
}