685ac5WN-ODOVOGA WN 3 10 12 13 14 15 17 18 IMPORTANT: 22 23 24 Exclude any existing source code files that may already b

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

685ac5WN-ODOVOGA WN 3 10 12 13 14 15 17 18 IMPORTANT: 22 23 24 Exclude any existing source code files that may already b

Post by answerhappygod »

685ac5wn Odovoga Wn 3 10 12 13 14 15 17 18 Important 22 23 24 Exclude Any Existing Source Code Files That May Already B 1
685ac5wn Odovoga Wn 3 10 12 13 14 15 17 18 Important 22 23 24 Exclude Any Existing Source Code Files That May Already B 1 (210.08 KiB) Viewed 35 times
685ac5WN-ODOVOGA WN 3 10 12 13 14 15 17 18 IMPORTANT: 22 23 24 Exclude any existing source code files that may already be in your IDE project and add a new one, naming it C1A3E1_main.c. Write a program in that file to compute and display a table of factorials. The factorial of an integral value n, written n!, is the product of the consecutive integers n down through 0. Since 0! is defined as having a value of 1 it can be omitted from the calculations since it does not affect the outcome. For example, 5 factorial (5!) can be calculated as 5 x 4 x 3 x 2 x 1 and has a value of 120. Below is a table of 1! through 7! nbr nbr! 25 26 27 28 29 30 31 32 83 34 35 36 37 38 39 40 41 42 43 44 45 34467NT 2 1. 2. 5 19 Your code must use a type long (not unsigned long) variable to represent the value of factorial nbr! in 20 the table above. The results must be correct up to the maximum value type long can represent on any and every machine on which your unaltered code is compiled and run. Since compiler manufacturers 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 conceivably be so great that hundreds of digits would be required to represent it. 21 1 2 6 24 120 720 5040 In addition to the above requirements, your program must: Prompt the user to enter an integer value greater than 0 and store it in a type int variable. 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. 3. 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 will not run together. 4. Use a row of hyphens to separate the column titles from the values. 5. Not use floating point literals, floating point variables, floating point functions, or floating point type casts. Not use an if statement or more than 1 looping statement. 6. 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 the 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 is increased sufficiently. 46 47 48 49 50 Suggest a possible way, without restricting user input or the number of values output, the program could 51 be modified so that all values would be correct, but do not incorporate your suggestion into the code you will be submitting for grading. Instead, merely place your suggestion as a comment in the file's "Title Block". Note that even using type unsigned long long or type long double will not eliminate 54 eventual erroneous values. 52 53
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply