1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Natalija [7]
3 years ago
14

Create the logic for a program that continuously prompts a user for a numeric value until the user enters 0. The application pas

ses the value in turn to a method that computes the sum of all the whole numbers from 1 up to and including the entered number, and to a method that computes the product of all the whole numbers up to and including the entered number.
Computers and Technology
1 answer:
emmainna [20.7K]3 years ago
4 0

Answer:

// here is code in C++.

#include <bits/stdc++.h>

using namespace std;

// function to compute sum and product

void sum_prod(int input)

{

   int sum=0;

   long long product=1;

   // compute sum of all from 1 to input number

   for(int i=1;i<=input;i++)

   {

       sum=sum+i;

   }

   // print sum

   cout<<"sum of all from 1 to "<<input<<" is:"<<sum<<endl;

   // compute product of all from 1 to input number

   for(int i=1;i<=input;i++)

   {

       product=product*i;

   }

   // print product

   cout<<"product of all from 1 to "<<input<<" is:"<<product<<endl;;

}

// driver function

int main()

{

   int n;

   cout<<"enter the number (0 to stop):";

   // read the input number

   cin>>n;

   // repeat until the user enter 0

   while(n)

   {

   // call the function to compute sum and product

      sum_prod(n);

      cout<<"enter the number (0 to stop):";

      cin>>n;

   }

return 0;

}

Explanation:

Read a number from user. Then call the function to calculate the sum and product of all number from 1 to input. In the function sum_prod(),create two variables "sum" and "product" to calculate the sum and product. Then print the output.This function will be called until user enter 0 an input.

Output:

enter the number (0 to stop):5

sum of all from 1 to 5 is:15

product of all from 1 to 5 is:120

enter the number (0 to stop):10

sum of all from 1 to 10 is:55

product of all from 1 to 10 is:3628800

enter the number (0 to stop):0

You might be interested in
You are trying to access the Wi-Fi network at a coffee shop. What protocol will this type of wireless networking most likely use
Anna71 [15]

The wireless network is called WAP protocol

8 0
3 years ago
If 400 Pa of pressure is applied to an area of 55 m2, which is the resulting force?
Free_Kalibri [48]
Formula is
Force=pressure x area
So the answer would be
400 x 55= 22000N
7 0
4 years ago
Read 2 more answers
Write the code to compute and output how many times the value 99 is found in an array of integers named numbers
astraxan [27]
Thank you for being the rare question where you actually provide what language you want your answer in; I approve, and encourage this.

In Java, the following will work.
I made it a bit more versatile to work with others numbers, other than 99, if you so please (if not, just hardcode the 99 in yourself).

// Example list - fill this with numbers yourself.
ArrayList<Integer> nums = new ArrayList<>();
int n = 99;
int count = (int)nums.stream().filter(i -> i == n).count();
System.out.println(n + " occurences.");
8 0
4 years ago
Glven an array named Scores with 25 elements, what is the correct way to assign the 25th element to myScore? A. myScores + 25 B.
Marat540 [252]

Answer:

myScore Scores[24]

Explanation:

The array is used to store the data in continuous memory location.

The index of array start from zero, it means first element store in the index zero and second element store in the index 1. So, the index at which the element store is less than 1 from the number of element.

so, the last element is 25 - 1=24.

Option A: myScores + 25

It is not the correct way to store the element.

Option B: myScore Scores[24]

it is the correct form and also the index location is correct.

Option C: myScore Scores[25)

index number is wrong and also the bracket is wrong, it must be [ ].

Option D: myScore== Score[last]

It is not the correct way to store the element.

There, the correct option is B.

6 0
3 years ago
How has the widespread shift to remote work caused businesses to reconsider their use of Extended Reality (XR)?.
romanna [79]

The widespread shift to remote work has caused businesses to reconsider their use of Extended Reality (XR) by inspiring them to re-imagine employee experiences and engagement with XR capabilities.

<h3>What is Extended Reality?</h3>

Extended Reality (XR) refers to an umbrella terminology that is used to describe all real and virtual physical environments (realities) and human-machine interactions through the use of various computer technologies and wearables.

In Business management, Extended Reality (XR) are typically used by employers of labor to boost workforce performance, engagement, retention and deliver better experiences to both their employees and customers (clients).

In terms of widespread shift to remote work, businesses have reconsidered their use of Extended Reality (XR) by re-imagining employee experiences and engagement with XR capabilities, so as to boost workforce performance, engagement, and retention.

Read more on Extended Reality here: brainly.com/question/26479902

4 0
3 years ago
Other questions:
  • Consider the following code.
    10·1 answer
  • If your computers normal zoom is 100, but it looks like its at 500, how do you stop that? my invisioned thing isn't on, neither
    9·1 answer
  • It is a field that contains a unique identifier for each record in a primary table
    5·1 answer
  • Which of the following “invisible” marks represents an inserted tab?
    11·2 answers
  • Write a program in Cto define a structure Patient that has the following members
    12·1 answer
  • Mencione algunos ejemplos en donde sean utilizadas las máquinas de aire comprimido. Justifique su respuesta.
    7·1 answer
  • Why computer is known as versatile and diligent device? Explain​
    7·1 answer
  • 8.10 quiz edhesive A swap is: a variable used to find the smallest value in an array an algorithm used to find a value in an arr
    12·1 answer
  • What is the half of 3/18
    6·1 answer
  • Many physical features of CPUs have been upgraded over the years. Below are some the features that latest CPUs can perform. Brie
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!