Â
#include <stdio.h>
int main()
{
int x[5];
int i = 0, sum = 0;
int *ptr;
ptr = x; //pointer stores address of an array
printf("Input 5 elements:\n");
//inputting elements of an array
for (i = 0; i < 5; i++)
{
scanf("%d", x + i);
}
for (i = 0; i < 5; i++) //sum of elements of an array using pointer
{
sum = sum + *ptr;
ptr++;
}
printf("Sum of elements of array:%d", sum);
return 0;
}
//..........Coded by Ananya Maurya
#ENJOY CODING
Post a Comment
FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP