Rotate your phone or change to desktop for better experience

Rotate your phone or change to desktop for better experience

Write a program in C to copy the elements of one array into another array

 // Write a program in C to copy the elements of one array into another array

#include <stdio.h>

int main() {
   
    int a[100],b[100];
    int n,i;
   
    printf("enter number of elements\n");
    scanf("%d",&n);
   
    for ( i = 0 ; i < n ; i++)
    {
        printf("enter a number : ");
        scanf("%d",&a[i]);
    }
   
   for (i =0 ; i < n ; i++)
   {
       b[i]=a[i];
   }
   printf("numbers in array 2 are\n");
   
   for (i = 0 ; i < n ; i++)
   {
   printf("number %d : %d\n",i+1,b[i]);
   }
   
    return 0;
}

Post a Comment

0 Comments