Monday , October 23 2017
Home / c-program / C Program to add elements of an array

C Program to add elements of an array

How to add elements in an array using C Program.

Add elements of an Array :


#include<stdio.h>
int main(void)
{
    int arr[10],i,total=0;
    for(i=0; i<10; i++)
    {
        printf("Enter value for arr[%d] : ",i);
        scanf("%d",&arr[i]);
        total+=arr[i];
    }
    printf("Total : %d\n",total);
    return 0;
}

Enter value for arr[0] : 10
Enter value for arr[1] : 20
Enter value for arr[2] : 30
Enter value for arr[3] : 40
Enter value for arr[4] : 50
Enter value for arr[5] : 60
Enter value for arr[6] : 70
Enter value for arr[7] : 80
Enter value for arr[8] : 90
Enter value for arr[9] : 100
Total : 550

Happy Learning 🙂

About chandrashekhar

Hi Folks, you have reach this so far, that shows you like what you are learning. Then why don't you support us to improve for bettor tutorials by leaving your valuable comments and why not you keep in touch with us for latest updates on your favorite blog @ facebook , twitter , Or Google+ ,

Recommended

C Program – Find Largest and Smallest number in an Array

C Program to find the largest and smallest number in an array. Largest and Smallest …

Leave a Reply

Your email address will not be published. Required fields are marked *