Question

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;

0 0
Add a comment Improve this question Transcribed image text
Answer #1

1)
11

2)
15

3)
Error: the code will not compile

4)
29

5)
625
Add a comment
Know the answer?
Add Answer to:
What is the output of the following code snippet? (If there is some kind of syntax...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 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 fly = 5; int x;        if (fly-- > 5)               x = 5;        else               x = 2;        if (x++ > 3)               cout << x;        cout << fly << endl; 2.   int i = 0;        bool b = i == 0 || i++ > 0;        if (!b)               cout << i << endl;        else               cout...

  • 51. What is the output of the following code snippet? int number = 0; int ptr_num...

    51. What is the output of the following code snippet? int number = 0; int ptr_num -&number ptr_num 60; number-80 cout < "ptr num << endl b, 60 c. 80 d. the address of number Answer 52. What is the output of the following code snippet? double num-0.0; double* ptr = &num; num = 15.0; ptr ptr 15.0 cout << num <<"ptr <<endl; a. 15 15 b. 15 30 С. 30 15 d. 30 30 Answer: 53. What is the...

  • QUESTION 1 What is the output of the following code snippet? int main() { bool attendance...

    QUESTION 1 What is the output of the following code snippet? int main() { bool attendance = false; string str = "Unknown"; attendance = !(attendance); if (!attendance) { str = "False"; } if (attendance) { attendance = false; } if (attendance) { str = "True"; } else { str = "Maybe"; } cout << str << endl; return 0; } False True Unknown Maybe QUESTION 2 What is the output of the following code snippet? #include <iostream> #include <string> using...

  • points): Show the output of the code below as it would appear on the monitor. int...

    points): Show the output of the code below as it would appear on the monitor. int main cout <<" <<endl: int wildcat 2: while (wildcat > 5) cout << wildcat <<endl; wildcat++ cout <K*<< endl; int jayhavk 5i do cout << jayhawk <s endl: while (jayhawk0) cout <<*" << endl; int wolverine l: while (wolverine 0 &&wolverine < 10) cout << wolverine <<endl: wolverine2: cout <<" <<endl: for (int zag-4; zag>0; zag_) cout <<****" << endl; for (int i-10; i<-30;...

  • 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 = 25; j > 16; j -= 3)        cout << setw(5) << j;     Answer: 2. int sum = 0;       for (int k = -2; k <= 2; k++)         sum = sum +...

  • QUESTION 9 What will be the output of following code snippet? int a[3] = {1, 2,...

    QUESTION 9 What will be the output of following code snippet? int a[3] = {1, 2, 3};         int *p = a;         int **r = &p;         printf("%p %p", *r, a); A. Different memory addresses printed B. 1 2 C. Same memory address printed twice D. 1 1 2 points    QUESTION 10 What will be the output of following code snippet? int arr[4] = {1, 2, 3, 4};         int *p;         p = arr + 3;         *p = 5;         printf("%d\n", arr[3]); A....

  • What is the output from running the following code snippet. void mystery(Queue<int>& q) { Stack<int> s;...

    What is the output from running the following code snippet. void mystery(Queue<int>& q) { Stack<int> s; while (!s.isEmptyQueue()) { s.push(q.front()); q.deleteQueue(); } while (!s.isEmptyStack()) { q.addQueue(2 * s.top()); s.pop(); } } Queue q; q.addQueue(8); q.addQueue(4); q.addQueue(18); q.addQueue(7); q.addQueue(5); mystery(q); cout << "["; while (!.isEmptyQueue()) { cout << " " << q.front(); } cout << " ]" << endl;

  • Please help! Studying for my c++ test! What does the following code produce? include <iostream>   ...

    Please help! Studying for my c++ test! What does the following code produce? include <iostream>    using namespace std; void my_function(int n); void main() {     my_function(546); } void my_function(int n) {     if (n < 10)         cout << n << endl;     else     {         my_function(n/10);         cout << (n%10) << endl;     } } What is the output of the following code?                   int j=32, k=5, r;                   r = j ^ k;                   cout << r...

  • Consider the following C++code snippet and what is the output of this program? # include<iostream> using...

    Consider the following C++code snippet and what is the output of this program? # include<iostream> using namespace std; void arraySome (int[), int, int); int main () const int arraysize = 10; int a[arraysize]-1,2,3,4,5, 6,7,8,9,10 cout << "The values in the array are:" << endl; arraySome (a, 0, arraySize) cout<< endl; system ("pause") return 0; void arraySome (int b[], int current, int size) if (current< size) arraySome (b, current+1, size); cout << b[current] <<""; a) Print the array values b) Double...

  • 12. What is the output of the following C++ code? int x; int y; int *p...

    12. What is the output of the following C++ code? int x; int y; int *p = &x; int *q = &y; *p = 35; *q = 98; *p = *q; cout << x << " " << y << endl; cout << *p << " " << *q << endl; 13. What is the output of the following C++ code? int x; int y; int *p = &x; int *q = &y; x = 35; y = 46; p...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT