# What will be the value of x after the following code is executed?

66 views

## Problems:

What will be the value of x after the following code is executed?
``````int x, y = 4, z = 6;
x = (y++) * (++z);``````

A) 24
B) 28
C) 30
D) 35

I am new to programming , Can anyone help me ?

## Solutions:

The value of x

``````int x, y = 4, z = 6;
x = (y++) * (++z);``````

is 28.

y++ evaluates y, then increments it (post incrementation)

++z increments z, then evaluates it (pre incrementation)

so

y=4, y++

z=6, ++z which will first increase z value from 6 to 7

z=7

x=4*7

x=28

Hope this solution will help.

## Related questions

29 views
Problem: What will be the value of x after the following code is executed? int x = 10, y = 20; while (y < 100) { x += y; } A) 90 B) 110 C) 210 D) This is an infinite loop.
32 views
Problems: I am new to programming, I need help, can anyone help me? What would be the value of discountRate after the following statements are executed? double discountRate = 0.0; int purchase = 1250; char cust = 'N'; if (purchase > 1000) if (cust == 'Y') discountRate = .05; else ... (cust == 'Y') discountRate = .04; else discountRate = .03; else discountRate = 0; a) .04 b) .03 c) .05 d) 0
135 views
Problem: I am new in programming and when running below code getting some unexpected error, can anyone help me with right result after running this code? Given the following code, what will be the value of finalAmount when it is displayed? public class Order { ... getOrderAmount() - order.getOrderAmount() * order.getOrderDisc(); System.out.println("Final order amount = \$" + finalAmount); } }
48 views
Problem: I am little bit confused and need help regarding my query? Which of the following expressions will determine whether x is less than or equal to y? A) x > y B) x =< y C) x <= y D) x >= y
12 views
Problem: Hello programmers! I am learning to program, and I just got a little confused about boolean values and logical operators. I tried to run the following program: #include<iostream> using namespace std; int main() { bool check = false && true || true; ... program, I got the following output: Condition evaluated to true I am so confused about how this condition evaluates to true. Any help?
20 views