Question: 1. Using a for loop, list all odd numbers from 1 to 20 on the Console window. Start your counter at 1 and jump directly

1. Using a for loop, list all odd numbers from 1 to 20 on the Console window. Start your counter at 1 and jump directly to the next odd number by incrementing your counter variable appropriately. This loop must not iterate 20 times. (4 points)

2. Using a while loop, list all even numbers from 1 to 20. In this problem, your counter variable must move from 1 to 20 and it must assume all values from 1 to 20 i.e. you cannot make the counter variable skip from 2 to 4. This loop must iterate 20 times. The remainder operator (%) gives you the remainder, e.g. 4%2 is 0 (since the 4/2 results in a remainder of 0). Use the remainder operator and an if statement to determine if the number is even. (4 points)

3. Write a short code segment that asks the user for a number and calculates the factorial for that number. The factorial of the number n is defined as the product of all the integers from 1 to the number n. For example, 4! = 4 * 3 * 2 * 1 = 24. Use either a while or a for loop. You will need to ask the user for a number and then utilize that as the starting value of your loop counter. Count down and keep multiplying while your counter is above zero. (4 points)

4. Reproduce the following triangle. Your code must produce the triangles using loops to produce all repetition of the asterisk character. The triangle should have 10 levels, with asterisks on each successive level decreasing by 1. Hint: notice the relationship between the line number and the number of asterisks on that line (6 points)

5. Create a small program segment, which asks the user to enter 2 scores each for 3 students and tells the user the average of all scores entered. Utilize a nested loop structure to ask for scores. (6 points) Use the outer for to loop through 3 times (looping through students). Use the inner for to loop through 2 times (looping through scores for each student). Decide in which loop, outer or inner, you will place the code to prompt the user and read the scores. The prompts should tell the user which student/score is being recorded, e.g. Student 1 - enter score 1: . Use the counter variables of the two loops to find out which student/score is the current one. Youll need to offset the counters by 1 in the WriteLine! You will need to use the accumulated totals structure to maintain a running total of all scores as well as keep a track of how many scores have been entered. Do not hardcode the number of scores. Finally calculate the average and print it to the Console.

6. Create a multiplication table that shows the numbers 5 through 10 multiplied by the following five numbers: 10, 20, 30, 40, 50. (6 points) This must be done only using nested loops. Show the multiplication equation as well as the product: 5 * 10 = 50 5 * 20 = 100 5 * 30 = 150 5 * 40 = 200 5 * 50 = 250 and so on. Produce a clean tabular format, using place-holders, as shown in the sample output. All of your values should be inserted into your Write statement using placeholders. Use commas with the placeholders to specify the width of the columns. You might need to use a mix of right and left justification. Each set of multiplication should be separated by a new line as seen in the sample output.

1. Using a for loop, list all odd numbers from 1 to

20 on the Console window. Start your counter at 1 and jump

directly to the next odd number by incrementing your counter variable appropriately.

file:///C:/Temp/A3/A3/bin/Debug/A3.EXE CIS 348 Assignment 1, Part 1 - odd Numbers 135 7 9 11 13 15 17 19 CIS 348 Assignment 1, Part 2 Even Numbers 2468 1 12 14 16 18 28 CIS 348 Assignment 1, Part 3 factorial Enter a number for the factorial:5 The factorial is 120 IS 340 Assignment 1, Part 4 Triangle Press any key for next page

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!