C Program to Compute sum of the array elements

C Program to Compute sum of the array elements

#include<stdio.h>

main()
{

 int arr1[5],arr2[5],arr3[5];     //declare 3 array. arr1+arr2 add and store in arr3
 int i;

//array1
printf("Enter array1 Elements:\n");     //print msg to enter array elements

  for(i=0;i<5;i++)
  {

   scanf("%d",&arr1[i]);       //user give inputs to array1

  }

//array2
printf("Enter array2 Elements:\n");      //print msg to enter array elements

  for(i=0;i<5;i++)
  {

   scanf("%d",&arr2[i]); //user give inputs to array2

  }

//array3
printf("Addition of array:\n");    //print msg

  for(i=0;i<5;i++)
  {

   arr3[i]=arr1[i]+arr2[i];

   printf("%d\n",arr3[i]);     //print Addition

  }

}



Related Posts