Ask 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 anymore numbers. Then the program should display the sum of those 10 positive number and also display the 10 positive numbers.

+3
Answers (1)
  1. 12 September, 19:12
    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?
Find 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 the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers