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

Consider the following code segment: pid_t pid; pid = fork(); if (pid == 0) { /*...
Consider the following code segment: pid_t pid; pid = fork(); if (pid == 0) { /* child process */ pthread_create( ... ); fork(); } pthread_create( ... ); fork(); the remaining code (not shown) does not call fork() nor call pthread_create(). Assume each invocation to fork() or pthread_create() was successful. a. How many unique processes are created (including the first main or root process)? Justify your answer. b. How many unique threads are created by pthread_create()? Justify your answer.
What output is produced by the following code fragment? int num = 0, max = 20;...
What output is produced by the following code fragment? int num = 0, max = 20; while (num < max) { System.out.println(num); num += 4; }
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...
Show the output of the following code segment. int count=0;                         for (int i=2; i <=...
Show the output of the following code segment. int count=0;                         for (int i=2; i <= 4; i++ ) {                                     StdOut.println(i);                                     for (int j=1; j <3; j++) {                                                 count++;                                                 StdOut.println(i +" " + j +" "+ count);                                     }                         } count i j I print 0 2 1 3 1 1 1 2 3 2 2 3 3 3 3 4 3 Show the output of the function call statements shown.             double x =...
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 + “ ”);...
The following code segment is stored in memory starting at memory location 0x00445670. What are the...
The following code segment is stored in memory starting at memory location 0x00445670. What are the two possible values for the contents of the PC after the branch instruction has executed?       bgez $a0, skip                      # mem location: 0x00445670 subu $s2, $s1, $t0 # branch NOT taken (false) ori    $v0, $t1, 0x0003 #       skip: addi $t0, $t1, 2 # branch taken (true) if taken: if not taken: Hint: Remember how many bytes each instructions takes.
Show what is written by the following segment of code, given item1, item2, and item3 are...
Show what is written by the following segment of code, given item1, item2, and item3 are int variable: item1 = 4; item3= 0; item2 = item1 + 1; stack.Push(item2); stack.Push(item2 +1); stack.Push(item1); item2 = stack.Top(); stack.Pop(); item1 = item2 + 1; stack.Push(item1); Stack.Push(item3); while (!stack.IsEmpty()) {      item3 = stack.Top():      cout <<item3<<endl;      stack.Pop(); } cout<<item1 <<endl <<item2<<endl<<item3<<endl;
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
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT