Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using C++ Write a programmer defined function that provides the factorial of a positive integer. Your main function should ask the user for the value

Using C++

Write a programmer defined function that provides the factorial of a positive integer. Your main function should ask the user for the value of an integer and pass this value to your programmer defined function. The programmer defined function needs to calculate the factorial, and return the factorial. You will need to display the factorial to the user in the main function.

Make sure: i) If the user enters 0, your function should return 1.

ii) If the user enters a negative number, your program should return -1. In your main function, display a suitable error message in this case.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Contemporary Issues In Database Design And Information Systems Development

Authors: Keng Siau

1st Edition

1599042894, 978-1599042893

More Books

Students also viewed these Databases questions

Question

Define Java and HTML5 and explain why they are important.

Answered: 1 week ago

Question

=+What kinds of problems need to be overcome?

Answered: 1 week ago

Question

=+Describe an important trade-off you recently faced

Answered: 1 week ago