Wednesday , January 17 2018
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 – Addition of two Matrices Example

C Program to Addition of two Matrices. Addition of two Matrices : Happy Learning 🙂

Leave a Reply

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