• Register
0 votes
158 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 ?

7 5 3
5,380 points

Please log in or register to answer this question.

1 Answer

0 votes

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.

 

8 6 2
10,530 points

Related questions

0 votes
1 answer 101 views
101 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.
asked Mar 9, 2020 ArifulIslam 7.5k points
0 votes
2 answers 40 views
40 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
asked Feb 14, 2020 maddi86 5.4k points
0 votes
1 answer 206 views
206 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); } }
asked Feb 18, 2020 maddi86 5.4k points
0 votes
1 answer 78 views
78 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
asked Feb 22, 2020 maddi86 5.4k points
0 votes
1 answer 28 views
28 views
Problem: Hello programmers! I want to know how many times will the following loop be executed? for(int i = 0; i<= 100; i = i+2) Moreover, what will be the value of &lsquo;i&rsquo; when this loop terminates? I am a beginner so I am so confused.
asked Jan 19 Code Learner 9.2k points
0 votes
1 answer 2 views
2 views
Problem: Does strcmp() work through each index of two arrays of characters and if the ASCII value is smaller at an identical index of two strings, that string is there alphabetically greater and therefore a 0 or 1 or 2 is returned?
asked 4 days ago ummesalma 25.2k points
0 votes
1 answer 1 view
1 view
Problem: What is the correct (most efficient) way to define the main() function in C and C++ &mdash; int main() or void main() &mdash; and why? And how about the arguments? If int main() then return 1 or return 0?
asked 2 days ago sumaiya simi 15.8k points
0 votes
1 answer 7 views
7 views
Problem: What is the point of using an else clause if there is a return instruction in the except clause? Thanks in advance
asked Mar 14 ummesalma 25.2k points
0 votes
1 answer 1 view
1 view
Problem: help me with this question: What is the equivalent code of the following statement in WHILE LOOP format? for (a=1; a<=100; a++) printf ("%d\n", a * a);
asked Apr 7 nabin 3.2k points