Question

1. Given the code snippet below, what is the value of c that is printed? int...

1. Given the code snippet below, what is the value of c that is printed?

int a = 3, b = 4, c;

a = 3; b = 4;
a *= b;
c = ++a * b--;
cout << "c is: " << c ;

Answer choices: 52, 32, 42

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

Ans: C is 52 (Option 1)

Explanation: a*=b means a=a*b = a=3*4 = 12

now, c= ++a*b--

since ++a means pre-increment so a's value is first incremented then multiplication occurs, so a becomes 13, b=4. As b-- is there which means post-decrement means after the operation will be performed then b's value will be reduced, hence 13*4= 52

So output value of c is 52.

Add a comment
Know the answer?
Add Answer to:
1. Given the code snippet below, what is the value of c that is printed? int...
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
  • 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...

  • What will be printed by the code below What will be printed by the code below...

    What will be printed by the code below What will be printed by the code below #include <iostream> using namespace std; class A { public: A() {cout << "+1";} ~A() {cout << "-1";} }; class B: public A { public: B() {cout << "+2";} ~B() {cout << "-2";} }; class C: public B { publc: C() {cout << "+3";} ~C() {cout << "-3";} }; int main() { A a1; B b1; A *a2 = new A; B *b2; = new...

  • What is wrong with the following code snippet? int main() { int width = 10; height...

    What is wrong with the following code snippet? int main() { int width = 10; height = 20.00; cout << "width = " << width << " height = " << height << endl; return 0; } The code snippet uses an uninitialized variable. The code snippet uses an undefined variable. The code snippet attempts to assign a decimal value to an integer variable. The code snippet attempts to assign an integer value to a decimal variable.

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

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

  • Consider the following code snippet. What will be printed by *ptr and ptr after the lines...

    Consider the following code snippet. What will be printed by *ptr and ptr after the lines shown. Explain with screenshots. int a[4] = { 8, 3, 5, 6}; int *ptr = a; ptr ++;

  • Language is C++ Complete the following Review Questions: 1. This is a control structure that repeats...

    Language is C++ Complete the following Review Questions: 1. This is a control structure that repeats a group of statements in a program? a. loop b. switch c. main() function d. compiler 2. In the expression number++,the ++operator is in what mode? a. Prefix b. Pretest c. Postfix d. Posttest 3.This is a variable that controls the number of iterations performed by a loop. a. Loop control variable b. Accumulator c. Iteration register variable d. Repetition meter 4. The do-whileloop...

  • What number will the following code snippet print? int numbers[8] = { 34, 42, 6, 11,...

    What number will the following code snippet print? int numbers[8] = { 34, 42, 6, 11, 29, 1, 89, 62}; cout << numbers[7];

  • 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?     int j = 47;     int i = 8;     j =...

  • Consider the code snippet given below. The variable sum is of type int. Will this compile?...

    Consider the code snippet given below. The variable sum is of type int. Will this compile? Explain why or why not int sum = 2 + ’2’;

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