Computer Science, asked by pr257997, 11 months ago

d)
Write a program in C++ to enter any 10 integers in 1 D array and
display the total sum of those digits.​

Answers

Answered by geethu18
3

Answer:

This is just the main program header files must be included

Attachments:
Answered by AskewTronics
0

Following are the program for the question above:

Explanation:

#include <iostream>//header file

using namespace std;

int main()//main function

{

    int a[10],sum=0,i; //variable declaration

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

  {

    cin>>a[i]; //take a user input

    sum=sum+a[i]; //sum the inputs

  }

   cout<<sum; //print the sum.

   return 0;

}

Output:

  • If the user inputs 1,2,3,0,0,0,0,0,0,0 then the output is 6.
  • If the user inputs 1,2,3,4,0,0,0,0,0,0 then the output is 10.

Code Explanation:

  • The above code is in c++ language which takes the 10 value and adds the value.
  • There is one array whose size is 10 and it takes the 10 value from the user.
  • Then the sum variable will add the 10 value and store it.
  • Then the print statement will print the value of the sum variable.

Learn More:

  • C++ program : https://brainly.in/question/7087341

Similar questions