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
Match the installation type to its description.
MariettaO [177]

Answer:

Following are the types of installation matched to its respective definitions.

<h3>Upgrade installation:</h3>

What you do when you have a computer with an existing operating system that needs to be upgraded.

This means that while working on a window when you get attracted by the update introduced recently and you upgrade your window accordingly.

For example: Updating a window from 8 to 10 or desired features.

<h3>Multiple boot installation:</h3>

What you do when you have several operating systems on one computer.

In this type of installation, a computer has different windows for different accounts. You can boot to the desired installed window by switching account.

<h3>Clean installation:</h3>

What you do on a brand new computer that has never been set up before and does not have an operating system on it yet.

It can be defined as the installation of window done very first time on to the computer. Sometimes when the window gets deleted due to virus or any other factor, the installation at that time will also be termed as Clean Installation.

<h2>I hope it will help you!</h2>
5 0
3 years ago
Coding with Loops Worksheet
vovangra [49]
Mmmmmmmmmmmmmmmmmmmmmmmm
7 0
3 years ago
Read 2 more answers
True or False: To create a function in python, you start with the keyword "def"
Butoxors [25]

Answer:

true i think

Explanation:

8 0
3 years ago
Read 2 more answers
Sequentially prenumbered forms are an example of a(n): a. Processing control. b. Data transmission control. c. Input control. d.
Stella [2.4K]

Answer:

Sequentially pre-numbered forms are an example of a(n):

c. Input control.

Explanation:

  • Such a type of control in which keep updating data on the basis of monitoring of data is known as Processing Control. Data matching is an example of processing control.
  • Data Transmission Control is such a control in which transmission of data    is done. Parity check is an example of data transmission control.
  • Input Control is such type of control in which user can perform different tasks like adding text. Sequentially pre-numberered forms and turn around documents are an example of an input control.
  • Examples of Data entry control include batch total and validity check.

7 0
3 years ago
What types of storage can be used to access data from another computer
Aleksandr-060686 [28]
<span>Hard disk drives
</span><span>RAM<span>Random access memory (RAM)
</span></span><span>External hard disks
<span>USB port
</span></span>CD and DVD drives
<span>Memory cards</span>
6 0
3 years ago
Read 2 more answers
Other questions:
  • What command in windows re gives you the opportunity to manage partitions and volumes installed on the system?
    7·1 answer
  • Juliet is trying to increase her savings account and she decides that she is going save an additional $700 every month. If her m
    9·1 answer
  • A user of the wireless network is unable to gain access to the network. The symptoms are:1.) Unable to connect to both internal
    6·1 answer
  • If a function needs to return more than one value, as a rule of good programming style, you should change it to a(n) ___________
    6·1 answer
  • How is marketing related to the other functions of a business
    14·1 answer
  • Advertising is organized around four distinct groups. The _____ group includes the photographers, the illustrators, video produc
    9·1 answer
  • What was your learning target for today
    9·2 answers
  • Write a formula that would return a TRUE result if the sum of the first five numbers in a column of data are negative
    7·1 answer
  • Can someone take away your points
    15·1 answer
  • The WordPress Widgets submenu is located where on the WordPress site?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!