Microsoft Visual C#
Microsoft Visual C#
7th Edition
ISBN: 9781337102100
Author: Joyce, Farrell.
Publisher: Cengage Learning,
bartleby

Videos

Textbook Question
Book Icon
Chapter 4, Problem 1RQ

What is the output of the following code segment? int a  =  3 ,  b  =  4 ; if ( = =  b ) ; Write ( " X " ) ; Write ( " Y " ) ;

  1. X
  2. Y
  3. XY
  4. nothing

Expert Solution & Answer
Check Mark
Program Plan Intro

To find:

Output of the given code segment.

Program Description Answer

b. Y

Explanation of Solution

In the given code in the first line, two int variables a and b have values as a = 3 and b = 4. Immediate next statement is If block statement.

If a statement is using equal to operator (==) to compare the value of both operands a and b .Equal to the operator will check if the operands on both sides of it are equal or not.

The operator will return false if operands are not equal and return true in case, they are equal.

Since a and b are not equal so if block will return false and hence the immediate next statement after it will not get executed.

The statement after the if block i.e. WriteLine("Y"); will get executed and hence the output will be Y.

Want to see more full solutions like this?

Subscribe now to access step-by-step solutions to millions of textbook problems written by subject matter experts!
Students have asked these similar questions
int test(int *x, int y){ x=&y; return(*x+y); } int main(void) { int x=1, y=6; test(&y, x); printf("%d %d %d", x, test (&y,x),y); return 0; } 1 2 6
int y=0,i; for (int i=0;i<10;++i) y+=i; 36 66 45 55
The value of x at the end.int x = 1;x = x + 1;x++;

Chapter 4 Solutions

Microsoft Visual C#

Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
C++ Programming Tutorial 36 - Intro to Loops; Author: Caleb Curry;https://www.youtube.com/watch?v=M3o7Y0juEP0;License: Standard YouTube License, CC-BY