Question

In: Computer Science

What is the output of the following code snippet? (If there is some kind of syntax...

What is the output of the following code snippet? (If there is some kind of syntax error indicate this by marking "error" in your answer choice)

1.

       int laps = 8;

       if (laps++ > --laps)

              laps += 2;

       else if (--laps > (laps - 1))

              laps += 4;

       else if (++laps)

              laps -= 3;

       cout << laps << endl;

2.

What is the output of the following code snippet?

  1.     int j = 47;
  2.     int i = 8;
  3.     j = (j / 3);
  4.     if (j / 2 > i && --i > (j /= 3))
  5.         j += i;
  6.     else
  7.     cout << j << endl;

3.

integer i = 67;
    double d = i - 1;
    i = d;
    character c = i;

    if i > 65
        cout << "The character is: " << c << " in the alphabet" << endl;
    else i <= 65
        cout << "The character is before the alphabet" << endl;

The character is: B in the alphabet

The character is: C in the alphabet

The character is: c in the alphabet

The character is before the alphabet

Error: the code will not compile

4.

What is the output of the following? (if there is a  syntax or runtime error enter “error” for your answer)
 
               int know = 4;
               short test = 5;
               long large = 28;
               
               if (large / 5 < test && ++test > know && ++test < large)
               {
                              test += know;
               }
               else if (--test == know++)
               {
                              test -= know;
               }
               large -= test;
               cout << large << endl;

5.

What is the output of the following code snippet? (If there is some kind of syntax error indicate this by marking "error" in your answer choice)

       //Note that there are no endl's until the end of the problem

       short k = 5;

       float red = 7.7f;

       if (++k < --red)

              cout << k;

       if (k < --red)

              cout << 4;

       if (++red > k--)

              cout << 2;

       cout << k << endl;

Solutions

Expert Solution



Related Solutions

• Based on the following code snippet and plan attributes, provide the output for Plan A,...
• Based on the following code snippet and plan attributes, provide the output for Plan A, Plan B and Plan C. Code Snippet • {{IF:[Copay]=Not Covered && [Coinsurance]=Not Covered, show ‘Not covered’}} • {{IF:[Copay]!=$0.00 && [Copay]!=Blank, show value from {{Copay}} copayment}} • {{IIF:[Copay]!=$0.00 && [CopayFrequency]!=Blank, show {{Copay}} copayment/{{CopayFrequency}}}} • {{IF:[CopayMax]=$0.00 OR [Copay]=$0.00, show No Charge}} • {{IF:[[CopayMax]!=$0.00 && [CopayMax] contains ‘$’ && [Coinsurance] contains ‘%’ && [CopayMaxFrequency]=Blank, show {{CopayMax}} copayment then {{Coinsurance}} coinsurance]}} Plan Copay CopayFrequency CopayMax CopayMaxFrequency Coinsurance Plan...
The following code has some syntax error. Please fixed the error. Besides, I want the output...
The following code has some syntax error. Please fixed the error. Besides, I want the output in ASCII characters. Please give me the corrected code along with the screenshot of the output. def cbc_dec(ys): int xs = [] int iv = ("0XAA", 16) #in decimal int key = ("0X08", 16) int x0 = chr(((163 * (int (ys[0], 16) - key)) % 256) ^ iv) xs.append(x0) for i in range (1, len(ys)): int xi = chr((( 163 * (int (ys[i], 16)...
I'm having trouble understanding the following code (a snippet of a code). What does it do?...
I'm having trouble understanding the following code (a snippet of a code). What does it do? The whole code is about comparing efficiencies of different algorithms. def partition(list,first,last): piv = list[first] lmark = first+1 rmark = last done = False while not done: while lmark <= rmark and list[lmark]<=piv: lmark=lmark+1 while list[rmark]>=piv and rmark>=lmark: rmark=rmark-1 if rmark<lmark: done = True else: temp = list[lmark] list[lmark]=list[rmark] list[rmark]=temp temp = list[first] list[first]=list[rmark] list[rmark]=temp return rmark
[50%] Code Snippet Given snippet code below that you are required to complete. You are not...
[50%] Code Snippet Given snippet code below that you are required to complete. You are not allowed to make a new function or change any given code. Please complete each section that are marked with the notation “INSERT YOUR CODE HERE”. Once you complete the snippet below, your output should have the same result with the given output below. Descriptions: [15%] isValid() This function is for checking that there is no duplicated employee data in the linked list. This function...
a. What will be the output of LINE A in code “a” and output of code...
a. What will be the output of LINE A in code “a” and output of code “b”? Also write reasons for the outputs. a. #include <sys/types.h> #include <stdio.h> #include <unistd.h> int value = 3; int main() { pid_t pid; pid = fork(); if (pid = = 0) {/* child process */} value += 233; return 0; } else if (pid > 0) {/* parent process */} wait(NULL); printf(“PARENT: value = %d”, value); /* LINE A */ return 0; } }...
identify the syntax errors in the following code:             public class Hello {                    &
identify the syntax errors in the following code:             public class Hello {                         private static int main(String [] args) {                                     string Msg=”Hello, Wrld!;                                     Sytem.out.println(msg+ “Ken")
Write a code snippet for the following:   You need to control the maximum number of people...
Write a code snippet for the following:   You need to control the maximum number of people who can be in a   restaurant at any given time. A group cannot enter the restaurant if they   would make the number of people exceed 100 occupants. Use random numbers   between 1 and 20 to simulate groups arriving to the restaurant. After each   random number, display the size of the group trying to enter and the number   of current occupants. As soon as the...
What is the output from each of the following segments of C++ code? Record the output...
What is the output from each of the following segments of C++ code? Record the output after the “Answer” prompt at the end of each program fragment. Assume all variables have been suitably declared. (Each problem is worth 3 points.) 1. for (int j = 8; j > 3; j -= 2)         cout << setw(5) << j;     Answer:      2. int sum = 5;    for (int k = -4; k <= 1; k++)         sum = sum...
a) i) The following VHDL code contains erroneous syntax. Re write the code in its corrected...
a) i) The following VHDL code contains erroneous syntax. Re write the code in its corrected format onto your answer sheet. You may assume that din is a 16-bit vector and that the ld, lr and cl inputs are 1-bit wide. lp: process(clk) signal reg : std_logic_vector(15 downt begin if cl=’1’ then reg := (others:=’0’); else if clk=’1’ and clkevent then if ld=’1’ reg <= din; end if; if lr=’1’ then reg := reg(14 downto 0) & “0 else reg...
Explain line-by-line what the following snippet code from a .htaccess (WordPress) file means: # Restricts access...
Explain line-by-line what the following snippet code from a .htaccess (WordPress) file means: # Restricts access to PHP files from plugin and theme directories RewriteCond %{REQUEST_URI} !^/wp-content/plugins/file/to/exclude\.php RewriteCond %{REQUEST_URI} !^/wp-content/plugins/directory/to/exclude/ RewriteRule wp-content/plugins/(.*\.php)$ - [R=404,L] RewriteCond %{REQUEST_URI} !^/wp-content/themes/file/to/exclude\.php RewriteCond %{REQUEST_URI} !^/wp-content/themes/directory/to/exclude/ RewriteRule wp-content/themes/(.*\.php)$ - [R=404,L]
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT