Q. Write a program to find the sum of elements of a given array, using DMA.
#AssignmentNo9
==> Code goes like this:
#include "stdio.h"
#include "stdlib.h"
int main() {
int *a,i,sum=0,size;
printf("\n Enter the size of array:");
scanf("%d",&size);
printf("\n Enter %d element of array:",size);
a=(int *)malloc(size*sizeof(int));
for (int i = 0; i <size ; ++i) {
scanf("%d",a+i);
sum=sum + *(a+i);
}
printf("\n The sum of array element is %d",sum);
return 0;
}
Output
If you have any confusion regarding the program, please, comment below.
Happy Coding !
Thank you
Finding sum of elements of given array using DMA- C
11:32 AM
C Programs
,
DMA in C
,
Dynamic Memory Allocation
,
pointer in c
,
Sum of array elements in C
,
Sum of array using DMA
Edit
0 comments:
Post a Comment