c program - addition of two array


#include<stdio.h>
int main() {
 int a[20], b[20], c[30], i, n;
 printf("Enter the number of elements to the array:\n");
 scanf("%d", &n);
 printf("\nEnter the  %d elements to the array A:\n", n);
 for (i = 0; i < n; i++) {
  scanf("%d", &a[i]);
 }
 printf("\nEnter the  %d elements to the array B:\n", n);
 for (i = 0; i < n; i++) {
  scanf("%d", &b[i]);
 }
 for (i = 0; i < n; i++) {
  c[i] = a[i] + b[n - 1 - i];
 }
 printf("\nC array elements are:\n");
 for (i = 0; i < n; i++) {
  printf("\n");
  printf("%d", c[i]);
 }
 return 0;
}


Output:


C prograaming, C programs, array



06 Aug 2015

Post a Comment

:) :)) ;(( :-) =)) ;( ;-( :d :-d @-) :p :o :>) (o) [-( :-? (p) :-s (m) 8-) :-t :-b b-( :-# =p~ $-) (b) (f) x-) (k) (h) (c) cheer
Click to see the code!
To insert emoticon you must added at least one space before the code.

 
Top