Too Tired? Too Anxious? Need More Time? We’ve got your back.
#1. Write a C# loop that starts at 1 and prints out all odd numbers less than 25 on one line. When the loop finds a number that is divisible by 3 OR 7 skip that number and do not print it out.
Example Output:
1 5 11 13 17 19 23
#2. Create an infinite while loop that prompts the user to enter a password. If the password they entered matches the string
“SecretPassword” exit the while loop and tell the user the password was correct.
#3 Request an integer number from the user. Using TryParse and a WHILE loop Verify that the user input an integer number. Then print out all positive integer numbers LESS THAN the input number.
Testdata:
userNumber: 5
Output:
4, 3, 2, 1
#4 Request two integer numbers (the first number MUST be less than the second number. You do not need to check for this, you can assume firstNum is less than secondNum) from the user. Using TryParse and WHILE loop Verify that the user input two integer numbers. Once you have verified that the numbers are integers, create a loop to examine all numbers between firstNum and secondNum:
Print out each odd number between firstNum and secondNum
Output the sum of each even number between firstNum and secondNum
Testdata:
firstNum = 1, secondNum = 10
Output:
each odd number between 1 and 10: 3, 5, 7, 9
total of each even number between 1 and 10: 20
#5 Create an outer for loop that will run 6 times using i as the variable and starting at 0. Within that outer for loop nest an inner for loop that will run 4times using j as the variable and starting at 0. Print out the values of i and j to the console as a grid so that a new line is only made right before i increases but not when j increases.
Output:
[i:0, j:0] [i:0, j:1] [i:0, j:2] [i:0, j:3] [i:0, j:4]
[i:1, j:0] [i:1, j:1] [i:1, j:2] [i:1, j:3] [i:1, j:4]
[i:2, j:0] [i:2, j:1] [i:2, j:2] [i:2, j:3] [i:2, j:4]
[i:3, j:0] [i:3, j:1] [i:3, j:2] [i:3, j:3] [i:3, j:4]
[i:4, j:0] [i:4, j:1] [i:4, j:2] [i:4, j:3] [i:4, j:4]
[i:5, j:0] [i:5, j:1] [i:5, j:2] [i:5, j:3] [i:5, j:4]
[i:6, j:0] [i:6, j:1] [i:6, j:2] [i:6, j:3] [i:6, j:4]
#6 Request two integer numbers from the user. Using TryParse and WHILE loop Verify that the user input two integer numbers. Using nested for LoopsPrint out a grid of *s that has as many ROWS as the first number and as many COLUMNS as the second number.
Testdata:
rows = 3, columns = 6
Output:
******
******
******
#7 Request one integer number from the user. Using TryParse and WHILE loop Verify that the user input one integer number. Using nested for Loops output * in the shape of a triangle to the console. The triangle will have as many columns in the first row as the input number and decrease the number of columns by 1 each row. Match the shape below.
Testdata:
size = 6
Output:
******
*****
****
***
**
*
#8 Extra Credit: Print the following shape out to the console using nested for Loops: (There is a space between each of the *)
*
* *
* * *
* * * *
#9 Extra Credit: Complete the bottom half of the diamond that you created for #8 using nested for loops:
HINT (Treat the bottom half of the Diamond like a completely separate operation with its own set of nested for loops)
*
* *
* * *
* * * *
* * *
* *
*
Too Tired? Too Anxious? Need More Time? We’ve got your back.