liyaahbear2068 liyaahbear2068
  • 02-09-2019
  • Computers and Technology
contestada

What is the result of expression 15 > 10 > 5 in C? What is the result of the same expression in Java?

Respuesta :

oscarporras02
oscarporras02 oscarporras02
  • 07-09-2019

Answer:

java: error

C: false

Explanation:

In Java the compiler understand that you are trying to compare an integer (15) with a boolean (10 > 5) this generate the next error:

error: bad operand types for binary operator  

In C the compiler convert (15 > 10 > 5) in (15>10) > (10>5) which is equal to TRUE > TRUE, the compiler can also read it as 1 > 1 (since 1 is TRUE and 0 is FALSE).  like 1>1 is false then C program return false.

Answer Link

Otras preguntas

Was the Renaissance a continuation of or a separate era of the Middle Ages?
If h = t and t = 14, which statement is true? A. h + t = 14 B. h > 14 C. h < 14 D. h = 14
Compared to a 26-gram sample of NaCl(s) at STP, a 52-gram sample of NaCl(s) at STP has(1) a different density(2) a different gram-formula mass(3) the same chem
calculate the time required for a 6000.-Newton net force to stop a 1200.-kilogram car initially traveling at 10. M/s
What is the formula for ANOVA
What genes are mutated to cause cancer?
Which quantity of heat is equal to 200. joules? (1) 20.0 kJ (3) 0.200 kJ (2) 2.00 kJ (4) 0.0200 kJ
CeeCee recorded the number of necklaces for sale at 10 different locations and then arranged the numbers from smallest to largest. The numbers of necklaces for
What is HDI? What factors influence the HDI of a country the most?
Identify the property shown. 3p · (2 + k) = 6p + 3pk A. transitive B. associative C. commutative D. distributive