This program allows the user to enter the size of an array and its elements, and then calculates the sum of all the elements:
#include<iostream> using namespace std; //Program to find Sum of element in an array. int main() { int a[100],n,i,sum=0; cout<<"\nEnter The Limit : "; cin>>n; for(i=0;i<n;i++) { cout<<"\nEnter The Value : "; cin>>a[i]; sum+=a[i];//sum=sum+a[i]; } printf("\nSum : %d",sum); return 0; }
Enter The Limit : 5 Enter The Value : 11 Enter The Value : 12 Enter The Value : 13 Enter The Value : 14 Enter The Value : 15 Sum : 65To download raw file Click Here
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions