Ask Question
9 March, 06:23

write a program in which the user can enter X amount of numbers. Once the user has enter 10 positive numbers, the user may not enter anymore numbers. Then the program should display the sum of those 10 positive number and also display the 10 positive numbers.

+1
Answers (1)
  1. 9 March, 09:07
    0
    The following code is in C++.

    #include

    using namespace std;

    int main () {

    int a[10], sum=0; //declaring an array and initialized variable sum with value 0.

    cout<<"Enter the numbers"<
    for (int i=0; i<10; i++)

    {

    cin>>a[i]; / /taking input of 10 integers.

    }

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

    {

    sum=sum+a[i]; //finding the sum ...

    }

    cout<<"The sum is : "<
    for (int i=0; i<10; i++)

    {

    cout<
    }

    return 0;

    }

    Output:-

    Enter the numbers

    1 2 3 4 5 6 7 8 9 10

    The sum is : 55

    The numbers entered are

    1 2 3 4 5 6 7 8 9 10

    Explanation:

    I have taken an array of size 10 so that no more than 10 integers could fit in it. After that taking the input from the user prompting 10 integers using the for loop. After that finding the sum. Then printing the sum and the numbers entered.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “write a program in which the user can enter X amount of numbers. Once the user has enter 10 positive numbers, the user may not enter ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers