Answer to Question #53758 in C for shivi

Question #53758
main( ) { int x = 10, y = 20 ; if ( x == y ) ; printf ( "\n%d %d", x, y ) ;
Expert's answer
You are declaring the x and y variables with values 10 for x and 20 for y. In next line you have small “trap”. You can see condition that if variable x equal variable y something must happen, but it will not work, because after closing bracket you see semicolon. Later you have function which will print x and y variables. In result the line of code “if ( x == y ) ;” is pointless.
If you will have code like this:
main( )
int x = 10, y = 20 ;
if ( x == y ) printf ( "\n%d %d", x, y );
In output you will see nothing, because condition “if ( x == y )” will work and variable x doesn't equal variable y, so those variables will not print.
In output you will see: 10 20.

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!


No comments. Be first!

Leave a comment

Ask Your question

New on Blog