Menus

Tuesday 21 April 2020

C program for add two one dimensional array


#include<stdio.h>

void main()
{

int a[10],b[10],c[10];
int n,i;

printf("Enter the size : ");
scanf("%d",&n);

printf("Enter first array \n");

for(i=0;i<n;i++)
 scanf("%d",&a[i]);

printf("Enter second array \n");

for(i=0;i<n;i++)
 scanf("%d",&b[i]);


for(i=0;i<n;i++)
 c[i]=a[i]+b[i];

printf("Sum of arrays : ");
for(i=0;i<n;i++)
 printf("\n%d",c[i]);


}




No comments:

Post a Comment