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

  Write the code

Write a program that allows an instructor to keep a grade book. Each students has scores for exams, homework assignments, and quizzes.

  Create constructor function which takes no inputs

You must have the constructor function which takes no inputs and randomly generates the 5 letter string for name and random integers from 20 to 40 for both age and class size.

  Write a program to crypt its input accordingly

Write a program to crypt its input according to a specified transformation scheme

  Sort an array of elements using the quick sort algorithm

Sort an array of 10,000 elements using the quick sort algorithm as follows: sort the array using pivot as the middle element of the array

  Supposed to swap numbers

The program is supposed to swap numbers, but I am stuck something is wrong! It does not swap them it repeats the second number, please help to fix! Thanks, this is in C++.

  Assume we have an array named $students

Assume we have an array named $students. Each entry in the array contains a student's full name (e.g. "Jane Smith"). Write the PHP code needed to display all students (in the array) whose first name starts with the letter "J".

  Program that asks the user to enter up to 100 integer score

Write a C program that asks the user to enter up to 100 integer scores, which are to be stored in an array. (You should allow the user to terminate input prior to entering all 100 scores.) The program should then display all the scores, ten per line,..

  Native method with deadlock detection and recovery

The naïve method with deadlock avoidance and the naïve method with deadlock detection and recovery - what will you measure and compare in order to determine the winner or which is better

  The stack-based routing scheme

the stack-based routing scheme you are to have a stack of maze locations.

  Enter the temperature at noon of each of the five days

Write a program that allows each employee to enter the temperature at noon of each of the five days and displays the highest, lowest, and average (mean) temps.

  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..

  Your main function will still prompt the user

Your main function will still prompt the user for the account number and service code. Based on the service code, main will ask for the correct number of minutes, then call your functions above as needed to finish the job. In addition you must.

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