forked from developerinsider/C-Programming-Example
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCpyAr.c
40 lines (33 loc) · 891 Bytes
/
CpyAr.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
/*******************************************************
Statement - Copy element of one array into another
Programmer - Vineet Choudhary
Written For - http://developerinsider.in
*******************************************************/
#include <stdio.h>
#include <string.h>
#include <conio.h>
void main()
{
int arr1[30], arr2[30], i, num;
clrscr();
printf("\nEnter no of elements :");
scanf("%d", &num);
//Accepting values into Array
printf("\nEnter the values :");
for (i = 0; i < num; i++)
{
scanf("%d", &arr1[i]);
}
//Copying data from array 'a' to array 'b'
for (i = 0; i < num; i++)
{
arr2[i] = arr1[i];
}
//Printing of all elements of array
printf("The copied array is :");
for (i = 0; i < num; i++)
{
printf("\narr2[%d] = %d", i, arr2[i]);
}
getch();
}