Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

3 points- C Pro de any existing source code files that may already be in your IDE project 2 Exclu 3 4 factorial of an

image text in transcribed
3 points- C Pro de any existing source code files that may already be in your IDE project 2 Exclu 3 4 factorial of an integral value n, written n!, is the product of the consecutive integers n 5 Since 0 is defined as having a value of 1 it can be omitted from the calcu 6 the outcome. For example. 5 factorial (5/) can be calculated as 7 120. Here is a table of 1! through 7 naming it C1A3E1 main.c. Write a program in that file to compute and display a ta and add a new one the down through 0 it doesn't affect 5 x 4 x 3 x 2 x 1 and has a value of ble of factorias. Th nbr nbr! 10 12 13 14 15 16 17 18 IMPORTANT 9 Your code must use a type long (not unsigned long) variable to represent the value of factorial nbr! in O the table above. The results must be correct up to the maximum value type long can represent on any 1 and every machine on which your unaltered code is compiled and run. Since compiler manufacturers 2 are allowed to make that maximum as great as they see fit as long as it is at least 2,147,483,647, it could 3 conceivably be so great that hundreds of digits would be required to represent it 24 120 720 5040 5 In addition to the above requirements, your program must 1. prompt the user to enter an integer value greater than 0 and store it in a type int variable: 2. compute and display a table like the one illustrated above for all values 1! through the factorial of the value entered by the user. Values must be displayed as decimal integers - no exponents or decimal points align the least significant digits in both columns for all entries in the table. Do not attempt to write code to compute the field widths needed for these columns. Instead, a fixed width of 2 for the 1st column and 11 for the 2nd is fine for the factorial values tested in this exercise unless you start getting misalignments or simply want to make them wider. Separate the fields with at least one space so the numbers won't run together Use a row of hyphens to separate the column titles from the values. 3. 4. 5. not use floating point literals, floating point variables, floating point functions, or floating point type casts: 6. not use an if statement or more than 1 looping statement 7. not use arrays or recursion; recursion occurs when a function is called before a previous call to that function has returned, for example, when a function calls itself Manually re-run your program several times, testing with at least the following 3 input values 1 25 36 If you find that any of the factorial values are incorrect determine if the expected values exceed t maximum value supported by type long on your machine, in which case they should be incorrect. Even if they are all correct they will eventually exceed the maximum if the user input value sufficiently. Suggest a possible way the program could be improved to extend its range, but don is increased incorporate your suggestion into the code you will lbe submitting for grading. Instead, merely place your suggestion as a comment in the file's "Title Block

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

Step: 3

blur-text-image

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

Expert Oracle Database Architecture

Authors: Thomas Kyte, Darl Kuhn

3rd Edition

1430262990, 9781430262992

More Books