Input some elements in an array and copy that array into another array using pointer.
#include <stdio.h>
#include <conio.h>
void input ( int arr[], int l )
{
int i;
for ( i = 0; i < l; i++ )
{
printf("\n\t\t Enter a number..:"); scanf("%d",arr+i);
}
}
void print ( int arr[], int l )
{
int i;
for ( i = 0; i < l; i++ )
{
printf("%d, ", *(arr+i) );
}
}
void copy ( int brr[], int arr[], int l )
{
int i;
for ( i = 0; i < l; i++ )
{
*( brr +i ) = *( arr + i );
}
}
void main ( )
{
int arr[10], brr[10];
clrscr ( );
input ( arr, 10 );
printf("\n\n\n The array is..:");
print ( arr, 10 );
copy ( brr, arr, 10 );
printf("\n\n The copied array is..:");
print ( brr, 10 );
getch ( );
}
Click here to contact us
#include <stdio.h>
#include <conio.h>
void input ( int arr[], int l )
{
int i;
for ( i = 0; i < l; i++ )
{
printf("\n\t\t Enter a number..:"); scanf("%d",arr+i);
}
}
void print ( int arr[], int l )
{
int i;
for ( i = 0; i < l; i++ )
{
printf("%d, ", *(arr+i) );
}
}
void copy ( int brr[], int arr[], int l )
{
int i;
for ( i = 0; i < l; i++ )
{
*( brr +i ) = *( arr + i );
}
}
void main ( )
{
int arr[10], brr[10];
clrscr ( );
input ( arr, 10 );
printf("\n\n\n The array is..:");
print ( arr, 10 );
copy ( brr, arr, 10 );
printf("\n\n The copied array is..:");
print ( brr, 10 );
getch ( );
}
Click here to contact us
No comments:
Post a Comment