write a program in c++ to enter any 10 integers in 1 D array & display the total sum of those digits
Answers
Answered by
2
Explanation:
#include <iostream. h>
using namespace std;
int main() {
int sum = 0;
int arr[10];
for(int i=0; i<10; i++) {
cin >> arr[i];
sum += arr[i];
}
cout << sum;
}
Answered by
0
Following are the programs for the above question :
Explanation:
#include <iostream>//header file.
using namespace std;
int main()//Main function.
{
int array_variable[10],increment=0,Total=0; //variable declaretion.
while(increment<10) //while loop
{
cin>>array_variable[increment];//take the value from the user into array variable.
Total=Total+array_variable[increment];//sum the value of array variable.
increment++;//increment operation for the loop.
}
cout<<"The sum is: "<<Total; //print the sum value.
return 0; //return statement.
}
Output:
- If the user input 1,2,0,0,0,0,0,0,0,0 then the output is 3.
- If the user input 1,2,0,0,0,0,0,0,0,3 then the output is 6.
Code Explantion :
- The above code is in c++ language which take the 10 value from the user, store it into array and add all the value.
- Ans then display the sum of all value entered from the user.
Learn More:
- C++ programing: https://brainly.in/question/12809215
Similar questions