Program to find sum of array elements using pointers || pointers || Arrays || C programming
In this, we are going to see a program in which we will find the sum of the array elements using pointers in C Programming Language.

//Program computing sum of the array elements using pointers

#include <stdio.h>

void main()
{
    int a[10];
    int i, sum = 0;
    int *p;

    printf("Enter 10 elements:\n");

    for (i = 0; i < 10; i++)
    {
        scanf("%d", &a[i]);
    }
    p = a;

    for (i = 0; i < 10; i++)
    {
        sum = sum + *p;
        p++;
    }

    printf("The sum of array elements is %d", sum);
}

#ENJOY CODING


Post a Comment

FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP

Previous Post Next Post