To do addition of all the Elements of Array in C++
C++ code to do addition of all elements in array :- #include<iostream> using namespace std; int main(){ int n ; cout<<"enter size if array : "; cin>>n; int arr[n]; cout<<"Enter "<<n<<" Array : "; for(int i=0;i<n;i++){ cin>>arr[i]; } cout<<"The array you entered is :"; for(int i=0;i<n;i++){ cout<<arr[i]<<" "; } cout<<endl; int sum=0; for(int i=0;i<n;i++){ sum+=arr[i]; } cout<<"the addition of all elements in the array is :" <<sum; return 0; } Output :- Video of Output :-
Comments
Post a Comment