The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 3 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
My problem is to complete a partially written C++ program that includes two functions that require a single parameter. The program continuously prompts the user for an integer until the user enters 0. The program then passes the value to a function that computes the sum of all the whole numbers from 1 up to and including the entered number. next the program passes the value to another function that computes the product of all the whole numbers up to and including the entered number. here is my code. I am trying to just call the function sums and no matter what I put in () I get an error when compiling I am trying to work in steps but can't get pass the first part. Following my book it seems like I am trying the right things but to no avail.Â
// SumAndProduct.cpp - This program computes sums and productsÂ
// Input:Â Interactive
// Output:Â Computed sum and product
#include <iostream>
#include <string>
int number1, number2;
void sums(int);//function declaration
void products(int);//function declaration
using namespace std;
int main()Â
{
  double number;             Â
       Â
  cout << "Enter a positive integer or 0 to quit: ";
  cin >> number;
  while(number != 0)
  { Â
     // Call sums function hereÂ
     sums(number);
     Â
   Â
     // Call products function here
    // products(int);
     Â
  }
  return 0;
} // End of main function
Â
// Write sums function here
//void sums(int number1, int number2)
//{
      //if number1
//sums = number1 + number2
// Write products function here
//products(int number1, int number2)
//Declarations
//int total
//products = number1 * number2