Question

In: Computer Science

Question 9 What is produced from the following code segment? val = 0; do { val++;...

Question 9

  1. What is produced from the following code segment?
    val = 0; do { val++; WriteLine(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

Question 10

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

    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

Question 11

  1. What is produced from the following code segment?
    for (int val = 10; val < 5; 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

Question 12

  1. Assuming val was described as an integer and an initial value of 10 and endVal is also declared as an integer with an initial value of 15, what is produced from the following code segment?
    while (val < endVal) 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

Question 13

  1. 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

Solutions

Expert Solution

Question 9
What is produced from the following code segment?
val = 0; do { val++; WriteLine(val); } while (val < 5);
=> Outputs 1 thru 5


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


Question 11
What is produced from the following code segment?
for (int val = 10; val < 5; val++) WriteLine(val);
=> Nothing is displayed


Question 12
Assuming val was described as an integer and an initial value of 10 and endVal is also declared as an integer with an initial value of 15, what is produced from the following code segment?
while (val < endVal) WriteLine(val++);
=> Outputs 10 thru 14


Question 13
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
**************************************************

Thanks for your question. We try our best to help you with detailed answers, But in any case, if you need any modification or have a query/issue with respect to above answer, Please ask that in the comment section. We will surely try to address your query ASAP and resolve the issue.

Please consider providing a thumbs up to this question if it helps you. by Doing that, You will help other students, who are facing similar issue.


Related Solutions

21. What is the output of the following segment of code if 7 is input by...
21. What is the output of the following segment of code if 7 is input by the user when asked to enter a number?____________ int num; int total = 0; cout << "Enter a number from 1 to 10: "; cin >> num; switch (num) { case 1: case 2: total = 5; case 3: total = 10; case 7: total = total + 3; case 8: total = total + 6; default: total = total + 4; } cout...
Complete the following code segment that is intended to extract the Dirham and fils values from...
Complete the following code segment that is intended to extract the Dirham and fils values from a price given as a floating-point value; for example, a price 2.95 yields values 2 and 95 for the dirham and fils. as per the following description: Assign the price to an integer variable named dirham to get the dirhmas part of the price Subtract dirham from price then multiply the difference by 100 and add 0.5 Assign the result to an integer variable...
no need to explain 11. What is output by the following code segment? boolean isHighTemp =...
no need to explain 11. What is output by the following code segment? boolean isHighTemp = true; double degree = 100.01; if (isHighTemp) if(degree >= 110) System.out.print(“Extremely Hot”); else System.out.println(“Not Hot”); A) Extremely Hot B) Not Hot C) Hot D) Extremely Hot Not Hot 12. To produce the output 2 4 6 8 10, what is the loop condition for the following loop? int n = 0; Page 3 do { n = n + 2; System.out.print(n + “ ”);...
in c++ QUESTION 4: Write the code to do the following: -read input from the keyboard...
in c++ QUESTION 4: Write the code to do the following: -read input from the keyboard by displaying the message on the screen to ask and read the following information: * customer ID (string) * customer name (string)                                                        * balance (float) -open output file customer .txt to write -Write to the output file customer.txt the following information:                 Customer ID – customer name – balance For example: 1561175753 - James Smith – 1255.25 -close file QUESTION 5: -create one notepad...
Write assembly code for the following machine code. Assume that the segment is placed starting at...
Write assembly code for the following machine code. Assume that the segment is placed starting at location 80000. Create labels for jump and branch instructions. Indicate the actual memory addresses represented by such labels. 0010 1010 0000 1000 0000 0000 0000 1010 0001 0001 0000 0000 0000 0000 0000 0010 0000 0010 0001 0001 1000 0000 0010 0000 0000 1000 0000 0000 0100 1110 0010 0101 0000 0010 0001 0010 1000 0000 0010 0000
a. Write machine code for the following assembly code. Assume that the segment is placed starting...
a. Write machine code for the following assembly code. Assume that the segment is placed starting at location 80000. Use decimal numbers to represent each instruction. loop:         beq $s3, $s1, endwhile                  add $t0, $s3, $s4                  lw $t1, 0($t0)                  add $s0, $s0, $t1                  addi $s3, $s3, 4                  j loop endwhile: b. Write assembly code for the following machine code. Assume that the segment is placed starting at location 80000. Create labels for jump and branch instructions. Indicate the actual...
what is the expected output of the following segment of code? dq = Deque() dq.push_back('M') dq.push_back('...
what is the expected output of the following segment of code? dq = Deque() dq.push_back('M') dq.push_back(' ') l = ['A', 'L', 'E', 'S', 'T', 'E'] for i in l: → if ord(i) % 3 == 0: → → dq.push_back(i) → elif ord(i) % 5 == 0: → → dq.push_front(i) → → dq.push_back(i) → elif ord(i) % 4 == 0: → → dq.push_back(i) → else: → → dq.peek_front() → → dq.push_front('X') → → dq.push_back('R') dq.push_front(dq.peek_back()) dq.pop_back() print(dq)
What is the output from the following program? Explain your results. file:///Users/brianabernal/Downloads/Question%201.pdf int val = 20;...
What is the output from the following program? Explain your results. file:///Users/brianabernal/Downloads/Question%201.pdf int val = 20; int func1() {     int val = 5;     return val; } int func2() {     return val; } int main() {     // (1)     cout << func1() << endl;     // (2)     cout << func2() << endl; }
For a 3 digit code with distinct numbers. (0-9) How many combinations to get the code...
For a 3 digit code with distinct numbers. (0-9) How many combinations to get the code (max)? How many combinations if you remember the middle number is 1?
Using existing Stack Java Collection Framework, write Java Code segment to do the following.   You may...
Using existing Stack Java Collection Framework, write Java Code segment to do the following.   You may write this in jGrasp Create a Stack of String called, myStacks Read input from keyboard, 10 names and then add to myStacks As you remove each name out, you will print the name in uppercase along with a number of characters the name has in parenthesis. (one name per line).   e.g.     Kennedy (7) Using existing Stack Java Collection Framework, write Java Code segment to...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT