Question

2.) In order to have a loop that allows the user to input 10 values, what...

2.) In order to have a loop that allows the user to input 10 values, what would be entered in the blank below:
int counter = _________;
while (counter < 10)
{
inputVal = Console.ReadLine();
++counter;
}

3.)What is produced from the following code segment?
for (int i = 1; i < 5; i++) WriteLine(i);

Nothing is displayed

Outputs 5 thru 9

Outputs 10

Outputs 1 thru 4

Outputs 1 thru 5

Outputs 10 thru 14

Outputs 0 thru 4

4.)

Assuming val was described as an integer and an initial value of 10, what is produced from the following code segment?
while (val < 10) WriteLine(val);

Nothing is displayed

Outputs 5 thru 9

Outputs 10

Outputs 1 thru 4

Outputs 1 thru 5

Outputs 10 thru 14

Outputs 0 thru 4

5.)

What is produced from the following code segment?
for (int val = 5, endVal = 10; val < endVal; val++) WriteLine(val);

Nothing is displayed

Outputs 5 thru 9

Outputs 10

Outputs 1 thru 4

Outputs 1 thru 5

Outputs 10 thru 14

Outputs 0 thru 4

6.) What is produced from the following code segment?
for (int n = 0; n < 5; n++) WriteLine(n);

Nothing is displayed

Outputs 5 thru 9

Outputs 10

Outputs 1 thru 4

Outputs 1 thru 5

Outputs 10 thru 14

Outputs 0 thru 4

7.)

What is produced from the following code segment?
val = 0; do { WriteLine(val); val++; } while (val < 5);

Nothing is displayed

Outputs 5 thru 9

Outputs 10

Outputs 1 thru 4

Outputs 1 thru 5

Outputs 10 thru 14

Outputs 0 thru 4

8.)

In order to have a loop that adds odd values from 10 through 20, what would be entered in the blanks below:
int oddAccumulator = 0;
for (int i = _____(need to answer)______; i < _____(need to answer)_________; i++)
{
if ((i % 2) != 0)
{
oddAccumulator += ______(needs an answer)_____;
}
}
WriteLine("The sum of odd integers in the range of 10 - 20 is: {0} ", oddAccumulator);

Homework Answers

Answer #1

2.ANSWER:

int counter = 0;

3.ANSWER:

   Output: 1 to 4

4.ANSWER:

   Nothing is displayed

5.ANSWER:

Output: 5 to 9

6.ANSWER:

   Output: 0 to 4

7.ANSWER:

    Output: 0 to 4

8.ANSWER:

int oddAccumulator = 0;
for (int i = 10; i <20; i++)
{
if ((i % 2) != 0)
{
oddAccumulator += i;
}
}
WriteLine("The sum of odd integers in the range of 10 - 20 is: {0} ", oddAccumulator);

if you have any queries regarding answers ,please ask me at comment section.

please give like.

thank you.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
1.) In order to have a loop that adds odd values from 10 through 20, what...
1.) In order to have a loop that adds odd values from 10 through 20, what would be entered in the blanks below: int oddAccumulator = 0; for (int i = [a]; i < [b]; i++) { if ((i % 2) != 0) { oddAccumulator += [c]; } } WriteLine("The sum of odd integers in the range of 10 - 20 is: {0} ", oddAccumulator); *I've figured out the answer for [a] = 10, [b] = 20, but I can't...
JAVA / I KNOW THERE IS MORE THAN ONE QUESTION BUT THEY ARE SO EASY FO...
JAVA / I KNOW THERE IS MORE THAN ONE QUESTION BUT THEY ARE SO EASY FO YOU I NEED YOUR HELP PLEASE HELP ME. I WILL GIVE UPVOTE AND GOOD COMMENT THANK YOU SO MUCH !!! QUESTION 1 What is the output after the code executes? Assume there are no syntax errors and the code will compile. int x = 10; do { System.out.println ( x ); x -= 3; } while (x > 0); A. 10 7 4 1...
4.2.2 Basic while loop with user input. JAVA Write an expression that executes the loop while...
4.2.2 Basic while loop with user input. JAVA Write an expression that executes the loop while the user enters a number greater than or equal to 0. Note: These activities may test code with different test values. This activity will perform three tests, with user input of 9, 5, 2, -1, then with user input of 0, -17, then with user input of 0 1 0 -1. See "How to Use zyBooks". Also note: If the submitted code has an...
This is an exercise using a while loop Input an integer n from the keyboard. Calculate...
This is an exercise using a while loop Input an integer n from the keyboard. Calculate the sum of the first n integers. So if n=10, the answer should be 55 (because 1+2+3+4+5+6+7+8+9+10=55) Code language: Java
In Java programming language 11.Create the code for a for loop to print the numbers 1  through...
In Java programming language 11.Create the code for a for loop to print the numbers 1  through 5 inclusive vertically so the output is 1 2 3 4 5 11b What is the output of the following               OUTPUT int i=3; while(int i >0) { System.out.println(i); i--; } 11c What is the output of the following               OUTPUT for(int i=3;i<10;i++) System.out.println(3*i); 11d Create the line of code to print the numbers 10 through 1 decreasing by 1 each time 11e Create the line of code...
1. How many times the loop below will be executed? What is the value of variable...
1. How many times the loop below will be executed? What is the value of variable counter after the loop? counter = 1 while counter < 7: counter+=2 print(counter) 2. An integer is stored in a variable MyInt. Write the Python if statement to test if MyInt is even number or odd number, and print a message to show “It is even number.” or “It is an odd number”. 3. Complete the python below that asks user to enter the...
q : explain the code for a beginner in c what each line do Question 2....
q : explain the code for a beginner in c what each line do Question 2. The following code defines an array size that sums elements of the defined array through the loop. Analyze the following code, and demonstrate the type of error if found? What we can do to make this code function correctly ? #include <stdio.h> #define A 10 int main(int argc, char** argv) { int Total = 0; int numbers[A]; for (int i=0; i < A; i++)...
Write a program that prompts the user to input a string and outputs the string in...
Write a program that prompts the user to input a string and outputs the string in uppercase letters. (Use dynamic arrays to store the string.) my code below: /* Your code from Chapter 8, exercise 5 is below. Rewrite the following code to using dynamic arrays. */ #include <iostream> #include <cstring> #include <cctype> using namespace std; int main() { //char str[81]; //creating memory for str array of size 80 using dynamic memory allocation char *str = new char[80]; int len;...
BASIC c++ question Please do not try to fix this, I just have a question regarding...
BASIC c++ question Please do not try to fix this, I just have a question regarding the function of this code. I understand this is an infinite loop, however, why is it that when I enter '0', it continues to ask the user for an input, but when I enter a letter, it continues infinitiy. And when it does infinitely loop, why is it that it continues to add 1 to each number? Doesn't the loop go through each line...
What is wrong with the following function: public static void funMethod() { int i=100; while (i...
What is wrong with the following function: public static void funMethod() { int i=100; while (i < 10) { System.out.println("i="+i); i++; } } Select one: a. loop control variable not declared b. loop control variable is never updated c. loop control variable not initialized d. loop control variable never resolves to true e. nothing is wrong with this code. What is wrong with the following function: public static void funMethod() { int i=1; while (i < 10) { System.out.println("i="+i); i++;...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT