0 votes
420 views
in Programming by (98.9k points)
edited
Write a program in C++, to read array of 10 elements and print its sum.

1 Answer

0 votes
by (98.9k points)
selected by
 
Best answer

#include<iostream>

using namespace std;

 int main()

  {

   int arr[10],i,sum=0;

   cout<<"Enter any  elements in Array: ";

   for(i=0;i<10;i++)

   {

   cin>>arr[i];

   }

   cout<<"Sum of all Elements are: ";


   for(i=0;i<10;i++)

   {

    sum=sum+arr[i];

   }

  

  cout<<sum;

  }


Output:: 

Related questions

Doubtly is an online community for engineering students, offering:

  • Free viva questions PDFs
  • Previous year question papers (PYQs)
  • Academic doubt solutions
  • Expert-guided solutions

Get the pro version for free by logging in!

5.7k questions

5.1k answers

108 comments

559 users

...