#include<stdio.h>
#include<stdlib.h>
int main()
{
int n, ans = 0, *p, i;
printf("Enter The Number Of Array Element : ");
scanf("%d", &n);
p = (int*) malloc(n * sizeof(int));
if(p == NULL)
{
printf("Error! memory not allocated.");
exit(0);
}
printf("\nEnter Element Of Array : ");
for(i=0;i<n;i++)
{
scanf("%d", p);
ans = ans + *p;
p++;
}
printf("\nSummation Of Array = %d\n", ans);
free(p);
return 0;
}
#include<stdlib.h>
int main()
{
int n, ans = 0, *p, i;
printf("Enter The Number Of Array Element : ");
scanf("%d", &n);
p = (int*) malloc(n * sizeof(int));
if(p == NULL)
{
printf("Error! memory not allocated.");
exit(0);
}
printf("\nEnter Element Of Array : ");
for(i=0;i<n;i++)
{
scanf("%d", p);
ans = ans + *p;
p++;
}
printf("\nSummation Of Array = %d\n", ans);
free(p);
return 0;
}
Comments
Post a Comment