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
The most common layout of keys on the keyboard is the _____ keyboard.
Alex
The most common layout is called "QWERTY" because it is the first six letters on the keyboard.
6 0
3 years ago
Read 2 more answers
What does the "mesh" do in Augmented Reality?
Brilliant_brown [7]

Mesh is used in VR and is the addition of the effects and objects to the room of virtual reality.

<h3>What is the role of Mesh?</h3>

Mesh allows the sharing of the reviews from any channel by the fact packages and enables the team to collaborate on the digital platforms to work on the three-dimensional projects.

The mesh allows the problem solving of the errors caused because of the microservices that disturb the functions, and permits the sharing of the holograms, doodles, and online avatars.

Learn more about mesh here:

brainly.com/question/22621708

#SPJ2

8 0
2 years ago
Read 2 more answers
In a bubble sort, you use a(n) ____ loop to make pair comparisons.
GarryVolchara [31]
In a bubble sort, you use an inner loop to make pair comparisons.
5 0
3 years ago
Briefly define "address space" and discuss its major tradeoffs (advantages/costs). What problem is it addressing?
vladimir1956 [14]

Answer:

The address space basically define the memory allocation for all the computational entity. It is basically define in the specific range in the memory which is available in the program.

The memory can be allocated in the resources like file, devices and server. In the address space the memory can be used either virtually or physically for executing the given instruction and storing the data in the system.

The main advantages and costs of the address space are that:

  • The simplifies the data migration and also the process migration the system.
  • It is easy to implement the zero cop.
  • It basically eliminate the copying of the data from the memory.  
  • The cost increase as the traditional operation system used a individual address space in the each processing.  

The small organization majorly face the problem of addressing and it also reduce the stability of the company and organization.

6 0
3 years ago
Do all careers or professions need computer science? Why or why not?
hjlf

Answer:

Most careers or professions need computer science

Explanation:

As humanity is improving technological wise most jobs will be replaced and other jobs would come into play and in order for individuals to become employed in jobs that will be available in the future to come they will have to have a degree in computer science or know how to operate computers.

8 0
3 years ago
Read 2 more answers
Other questions:
  • . Electricians will sometimes call ______ "disconnects" or a "disconnecting means."
    12·1 answer
  • Plssss helpppp!!<br><br>Thanks
    11·2 answers
  • Type the correct answer in the box.
    15·1 answer
  • Write an application that inputs three numbers (integer) from a user. (10 pts) UPLOAD Numbers.java a. display user inputs b. det
    10·1 answer
  • Where can i watch twilight breaking Dawn 2 full movie. In the internet where can i wath it for free
    14·1 answer
  • The ____ option must be used when running a program in order to see the results of assert statements.
    7·1 answer
  • Mk chưa hiểu nên các bạn giúp mk vs
    14·1 answer
  • Braxton is writing a program to design t-shirts. Which of the following correctly sets an attribute for color?
    7·1 answer
  • How does the autosum command calculate data? Need help ASAP​
    5·1 answer
  • quizlet ann is a security professional for a midsize business and typically handles log analysis and security monitoring tasks f
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!