Test 5 > run Enter integer: 7 Factors of all numbers up to 7 1: 1 2: 1, 2 3: 1, 3 4: 1, 2, 4 5: 1, 5 6: 1, 2, 3, 6 7: 1, 7 Test 6 >
run Enter integer: 21
Factors of all numbers up to 21
1: 1
2: 1, 2
3: 1, 3
4: 1, 2, 4
5: 1, 5
6: 1, 2, 3, 6
7: 1, 7
8: 1, 2, 4, 8 9: 1, 3, 9 10: 1, 2, 5, 10 11: 1, 11 12: 1, 2, 3, 4, 6, 12 13: 1, 13 14: 1, 2, 7, 14 15: 1, 3, 5, 15 16: 1, 2, 4, 8, 16 17: 1, 17 18: 1, 2, 3, 6, 9, 18 19: 1, 19 20: 1, 2, 4, 5, 10, 20 21: 1, 3, 7, 21
Programming Assignment
Your solution will be graded based upon program behavior (passing tests). Your solution will not receive full credit (or receives no credit) if you fail to follow these restrictions:
- Your program must compile and run. Otherwise it will receive a zero.
- Add your solution to the provided code template.
- Do NOT use the do-while statement. Only use the while and for statements where appropriate.
- Use descriptive variable names. Avoid too short variable names, especially single letter variable names.
- DO NOT start a variable name with a capital letter.
- DO NOT use == true or == false in your boolean expressions (see lecture notes).
- DO NOT use explicit type casting. Instead use coercion (see lecture notes).
- DO NOT unnecessarily use parenthesis in an expression, e.g. an equation or formula. Parenthesis should only be used for grouping portions of an expression to change operator precedence order. For example, parenthesis are unnecessary in the expression (a + b + c). Instead use a + b + c. Parenthesis are necessary in the expression (a + b + c) / 3.
- DO NOT use the break and continue statements in your solution.
- Your program must be readable including indenting, spaces, and avoid lines that are too long. Use the the sample programs in the lecture notes as a guide.
- Comment your program. Read the document at the "Lecture" link on Carmen under Modules->Commenting Your Program-> Commenting your program. DO NOT comment every line.
- Only use C++ statements presented in the course. I.e. statements and notation presented in the lecture notes and assigned readings.
To receive full credit, only use C++ statements presented in the lecture notes and assigned readings. Your solution will be graded based on passing test cases, formatting, and good choice of variable names. Write your solution in the provided code template.
Important!: Write your code incrementally. This means implement your solution one portion at a time where you compile, run, and test the code portion before moving on to the next portion. Use the provided test cases to help you arrive at your final solution.
TASK 3: Write C++ code to prompt the user for a positive integer. Repeatedly re-prompt the user if the value entered is not a positive value. Compile, run, and test this solution before continuing to the next task.
TASK 4: Write C++ code to display factors (comma separated) for each integer from 1 to the value entered in TASK 3.
-
Be sure that there is a comment documenting each variable (see the document on Carmen under Modules on how to comment your code).
-
Do not start a variable name with a capital letter. Be sure that your code is properly indented, readable, and use good descriptive names.
-
Test your solution.
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps with 2 images
- Write a program using tab panes for performing integer and rationalnumber arithmetic as shown in Figure .arrow_forwardGiven: string s; int first, last; Write code to repeatedly validate that first is less than last and both first and last are valid indexes of the string s. Then print all characters of the string s from index first to last inclusive. Example Output 1 Enter a string and two indexes: Queensborough 25 eens Example Output 2 Enter a string and two indexes: Science 2 10 Enter a string and two indexes: Science -15 Enter a string and two indexes: Science 2 4 ienarrow_forwardPlease helparrow_forward
- Please fix this code, so the answer is proper, not only 0's: .datax: .double 0:16 # initialize x to all zerosy: .double 0:16 # initialize y to all zerosz: .double 0:16 # initialize z to all zerosmsg1: .asciiz "Enter 16 values for y and z matrices: \n"msg2: .asciiz "Resulting x matrix: \n".text.globl mainmain: # Prompt user to enter values for y and z matrices la $a0, msg1 li $v0, 4 syscall # Input values for y la $t0, y li $t1, 16 li $v0, 7 yloop: beq $t1, $zero, zloop syscall sdc1 $f0, ($t0) addi $t0, $t0, 8 addi $t1, $t1, -1 j yloop # Input values for zzloop: la $t0, z li $t1, 16 li $v0, 7 zinner: beq $t1, $zero, multiply syscall sdc1 $f0, ($t0) addi $t0, $t0, 8 addi $t1, $t1, -1 j zinner # Multiply y and z matrices and store the result in xmultiply: la $t0, y la $t1, z la $t2, x # Loop over rows of x li $t3, 0rows: beq $t3, 4, print # Loop…arrow_forwardModule/Week 2 ASSIGNMENT (INPUT/OUTPUT)The number of permutations of a set of n items taken r at a time is given by the following formulan !⁄r !(n-r)!: where n! is the factorial of n, r! is the factorial of r, and (n-r)! is the factorial of the result of n-r. The factorial of a number n can be solved using the following formula: 〖n!=e〗^(-n) n^n√2πn. If there are 18 people in your class and you want to divide the class into programming teams of 3 members, you can compute the number of different teams that can be arranged using this formula (n !⁄r !(n-r)!). Write a C++ program that determines the number of potential team arrangements. You will need to use the double type for this computation. Use the Lab Template you set-up last week, proper formatting, and appropriate comments in your code. The output must be labeled clearly and formatted neatly. Submit C++ Programming Assignment 2 by 11:59 p.m. (ET) on Monday of Module/Week 2.arrow_forwardWhat is the function of a router in the OSI model, and which layer does it primarily operate in?arrow_forward
- Please enter a positive odd integer: 3 492 3 5 7 8 16 Please enter a positive odd integer: 5 11 18 25 2 9 10 12 19 21 3 4 6 13 20 22 23 5 7 14 16 17 24 1 8 15arrow_forwardYou will use sequential, selection and repetition programming statements. You will define one integer number: count count will store how many times valid weights and values have been entered. You will define a variety of doubles: weight, value, sum, sumw, avg value will store the input value weight will store the input weight for that value sum will store the running sum of values and weights sumw will store the running of the weights avg will store the weighted average of the 5 numbers and 5 weights input. The running sum will be calculated by this formula: sum = sum + value * weight For example, if the first value and weight pair entered is 4, 1 and second pair is 10, 3: sum = sum + value*weight = 0 + 4*1 sum = 4 + 10*3 = 34 sumw = 1 + 3 = 4 Values and sum are to be input and calculated within a repetition loop: while count < 5 Input value, weight sumw = sumw + weight sum = sum + value * weight count = count + 1 End while Avg is calculated by: avg =…arrow_forward11 // Identify the incorrect code by line number (i.e. 1, 6, 18). Enter one line number in each answer box. // This code snippet is from a program that inputs chararacters from B....... // UART RX1, echos back chars+1. 1.#include "pic24_all.h" 2.#include "std_io.h" 3.int main(void) { 4. uint8_t u8_c; 5. 6. configClock(); 7. configDefaultUART(DEFAULT_BAUDRATE); 8. 9. printf("\nHello World!\n"); 10. 11. // Echo character + 1; 12. while (1) { 13. u8 c = inChar(); //get character 14. outChar(u8_c); 15. 18 ctt: //echo the character //increment the characterarrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education