Create a boolean function that computes

Assignment Help C/C++ Programming
Reference no: EM13166806

Create a Boolean function that computes the value of a factorial for values up to including 10. Include comments about how to use the function and describing how it works.

The first parameter is the integer (int) for which you are calculating the factorial.

The second parameter is an integer (int) that must be passed by reference. Use the passed by reference parameter to return the result of the factorial operation.

Before you attempt to compute the factorial make sure that first parameter is a valid number for performing a factorial.

If the first parameter is not a valid number the function must return false.

If the first parameter is a valid number the number must return true and must return the factorial value in the second parameter as described above.

Create a void test function that is to be called from your main function.

In this test function call your factorial function several times using both valid and invalid values for the requested factorial. Be sure to cover all values that are just inside or outside the limits.

Do not use cin to obtain input from the user.

Write several calls to your factorial function. Be sure to capture and check the value of the bool returned by your function in every case.

Use cout to display a failure message on failures (include the invalid attempted factorial).

Use cout to display a success message on success. Include the requested factorial and the computed factorial value.

I only got to bool and I don't get the rest...

#include "stdafx.h"
#include <iostream>
#include <iomanip>
using namespace std;

bool ComputeFactorial(int first, int second);
void FactorialFunction()
{
  
}


bool ComputeFactorial(int first, int &second)
{
   {
       if (first > 0 && first <= 10)
       {
           second = 1;
           int n;
           for (n = 1; n <= first; n++)
           {
               second = second * n;
           }
           return true;
       }
          
       else
           return false;
   }
}


int _tmain(int argc, _TCHAR* argv[])
{
   FactorialFunction();
   system("pause");
   return 0;
}

Reference no: EM13166806

Questions Cloud

What is the mole fraction of ethanol in a solution : What is the mole fraction of ethanol in a solution made from mixing 299 grams of ethanol (C2H5OH) and 360 grams of water? (Round your answer to 2 places after the decimal.)
How to design a new isa : How to design a new ISA? What should take into consideration?
Design and implement an avl tree algorithm : Design and implement an AVL tree algorithm that searches a collection of documents. You will be provided with a set of 50 documents and a set of sample queries. First, you will process the documents and store their content (i.e. words / tokens) in..
A program computes and displays the number of centimeter : The Earth's ocean levels have risen an average of 1.8 millimeters per year over the past century. Write a program computes and displays the number of centimeters and number of inches the oceans rose during this time.
Create a boolean function that computes : Create a Boolean function that computes the value of a factorial for values up to including 10. Include comments about how to use the function and describing how it works.
Several views to cybersecurity architecture : several views to Cybersecurity Architecture. Describe the Business View and the Architect's View through a business case example.
Describe what is meant by cybersecurity design : Describe what is meant by Cybersecurity Design.List and describe the principles that must be supported.
Create a program that contains 4 methods : Create a program that contains 4 methods / functions... main(), getTestScores(), calcAverage(), and displayAverage(). The main() method should call the getTestScores() method to get and return each of 3 test scores.
Describe what is meant by cybersecurity architecture : Describe what is meant by Cybersecurity Architecture. List and describe the principles that must be supported.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Program that can serve as a simple calculator

Write a program that can serve as a simple calculator. This calculator keeps track of a single number (of type double) that is called result and that starts out as 0.0. Each cycle allows the user to repeatedly add, subtract, multiply, or divide by..

  Converts the temperature f in farenheit to c in celsius

Write a program that converts the temperature F in Farenheit to C in Celsius using C = (F-32)*5/9. For ease of programming you can display the result in fractions.

  How nested if-statements replace with one if-statement

Describe how following nested If-statements could be replaced with one if-statement using logical operator (And/Or/Not). Write down the C++ code example.

  Write a program that allows users to enter a dollar amount

Write a program that allows users to enter a dollar amount for their bank account balance at the beginning of the month. Then ask the user to enter a dollar amount for any number of checks written in a month, up to 50. Include an approriate sentinel ..

  Multiple choice question on c programming

Create a function to print "88 is a great port number" function name is yourName_PrintFunction no input no return type print "88 is a great port number"

  Design your application according to the considerations

Design your application according to the considerations described above.  For example, you must use functions that have the specified signatures, and arrays that have the specified declarations. They are

  Write a c++ program that would take two 3x3 matrix

Write a C++ program that would take two 3x3 matrix and outputs the results of adding, subtracting and multiplying two matrices. Create at least three functions: one that performs addition,

  Users to input two forces by their components

write a programm to ask users to input two forces by their components of (Fx1,Fy1) and (Fx2,Fy2) from the keyboard.call twice the function to display both magnitude and direction angle of two forces on the screen.add two forces and display both magni..

  Prepare a program for a retail-mart company

Prepare a program for a company Retail-Mart.

  C++ programming uml diagrams

The goal of this lab is to better familiarize you with polymorphism and the factory design pattern, two key components in Assignment

  Brownian motion is a physical phenomenon

Brownian motion is a physical phenomenon which can be observed, for instance, when a small particle is immersed in a liquid.

  Program to compute gross wages for employee using array

Write program which uses the following arrays: payRate: array of seven floats to hold each employee's hourly pay rate. wages: array of seven floats to hold each employee's gross wages.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd