AedenCak3

C Program to read two arrays from user, add them, and then output their sum

Dec 6th, 2021
576
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6.     int i,num;
  7.     printf("Enter the size of the arrays  :");
  8.     scanf("%d", &num);
  9.  
  10.     int arr1[num], arr2[num] , arr3[num] ;
  11.  
  12.     printf("enter elements in the array1 : ");
  13.  
  14.     for(i=0; i<num ; i++)
  15.     {
  16.         scanf("%d", &arr1[i]);
  17.     }
  18.  
  19.       printf("enter elements in the array2 : ");
  20.  
  21.     for(i=0; i<num ; i++)
  22.     {
  23.         scanf("%d", &arr2[i]);
  24.     }
  25.      
  26.  
  27.     for(i=0; i<num ; i++)
  28.     {
  29.         arr3[i]= arr1[i]+arr2[i];
  30.         printf("\n %d + %d = %d : : ", arr1[i], arr2[i] ,arr3[i] );
  31.     }
  32. return 0;
  33. }
  34.  
  35.  
RAW Paste Data