We appreciate your visit to What will be the values of ans x and y after the following statements are executed cpp int ans 35 x 50 y 50 if. This page offers clear insights and highlights the essential aspects of the topic. Our goal is to provide a helpful and engaging learning experience. Explore the content and find the answers you need!
Answer :
Answer:
B. ans = 60, x = 0, y = 50
Step wise Explanation of the code chunk
- The first statement assigns value 35 to ans variable, value of 50 to x variable and value of 50 to y variable.
- Next is an if statement which checks if the value of x variable is greater than or equal to y
- This condition is true as x = 50 and y = 50 So x = y
- Now since the statement is true it will enter the if block of the code which is the instruction: ans = x + 10; x -=y; and ignores the else block.
- This line changes the value of ans variable and assigns it the value obtained by adding 10 to the value of variable x.
- we know that x = 50
So
ans = x + 10
ans = 50 + 10
ans = 60
- After this, comes another line x -=y; which means decrement the value of x by value of y
that means:
x = x - y
x = 50-50
x = 0
- So the new value of ans is 60, new value of x is 0 and the value of y remains the same i.e. 50
Hence
ans = 60
x = 0
y = 50
Thanks for taking the time to read What will be the values of ans x and y after the following statements are executed cpp int ans 35 x 50 y 50 if. We hope the insights shared have been valuable and enhanced your understanding of the topic. Don�t hesitate to browse our website for more informative and engaging content!
- Why do Businesses Exist Why does Starbucks Exist What Service does Starbucks Provide Really what is their product.
- The pattern of numbers below is an arithmetic sequence tex 14 24 34 44 54 ldots tex Which statement describes the recursive function used to..
- Morgan felt the need to streamline Edison Electric What changes did Morgan make.
Rewritten by : Barada