-
Notifications
You must be signed in to change notification settings - Fork 0
/
lab2_4.c
75 lines (74 loc) · 1.66 KB
/
lab2_4.c
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
68
69
70
71
72
73
74
75
#include<stdio.h>
int main()
{
int a,x,v=0;
printf("Enter the array size \n");
scanf("%d",&a);
int a1[a],b1[a];
printf("Enter the array elements of 1st array: \n");
for(int i=0;i<a;i++)
{
scanf("%d",&a1[i]);
}
printf("Enter the array elements of 2nd array: \n");
for(int i=0;i<a;i++)
{
scanf("%d",&b1[i]);
}
printf("Enter the number \n");
scanf("%d",&x);
for(int i=0;i<a;i++)
{
for(int j=0;j<a;j++)
{
if(a1[i]+b1[j]==x)
{
v++;
printf("The pair of numbers are: %d,%d \n",a1[i],b1[j]);
break;
}
}
}
if(v==0)
printf("No pair found");
return 0;
}
A5)
#include<stdio.h>
int main()
{
int a,b,c;
printf("Enter the array sizes of 3 arrays \n");
scanf("%d%d%d",&a,&b,&c);
int a1[a],b1[b],c1[c];
printf("Enter the array elements of 1st array: \n");
for(int i=0;i<a;i++)
{
scanf("%d",&a1[i]);
}
printf("Enter the array elements of 2nd array: \n");
for(int i=0;i<b;i++)
{
scanf("%d",&b1[i]);
}
printf("Enter the array elements of 3rd array: \n");
for(int i=0;i<c;i++)
{
scanf("%d",&c1[i]);
}
printf("Common elements from the given three arrays: \n");
for(int i=0;i<a;i++)
{
for(int j=0;j<b;j++)
{
for(int k=0;k<c;k++)
{
if(a1[i]==b1[j] && b1[j]==c1[k])
{
printf("%d",a1[i]);
}
}
}
}
return 0;
}