About Me

My photo
Raipur, Chhattisgarh, India
Hi , I am Amit Thakur. I have worked as a QA Engineer for two years and as a Java Developer for one year in NIHILENT TECHNOLOGIES PVT. LTD., Pune.Currently I am working as DEAN (Research & Development) in Bhilai Institute of Technology, Raipur.

Monday, September 2, 2013

C Program to Copy all elements of an array into Another array

//Title : Copy Array Elements from one array to another
//a - Source Array ( elements will be copied from this array)
//b - Destination array ( elements copied into this array)
//---------------------------------------------------------------------
#include<stdio.h>
#include<conio.h>
void main()
{
int a[30],b[30],i,n;

// Element of an array 'a' will be copied into array 'b'

printf("n Enter no of elements :");
scanf("%d",&n);

/* Accepting values into Array a*/
printf("n Enter the values :");
for(i = 0 ; i < n ; i++)
scanf("%d",&a[i]);

/* Copying data from array 'a' to array 'b */

for(i = 0 ;i < n ; i++)
b[i]=a[i];

/* printing of all elements of array */

printf("the copied array is :");
for(i=0;i < n;i++)
printf("b[%d]=%d",i,b[i]);
getch();
}

No comments: