COMPUTER PROGRAMMING FUNDAMENTALS
PROGRAMMING LANGUAGES
Question
[CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
|
Which of these expressions will generate a logic error when the expected output is 10?
|
answer = 2 + 3 * 2
|
|
answer = (2 + 3) * 2
|
|
answer = 2 + 3 x 2
|
|
answer = {2 + 3} * 2
|
Explanation:
Detailed explanation-1: -Types of logic error be in the wrong sequence. have the wrong Boolean expression. use the wrong data type. be missing altogether.
Detailed explanation-2: -A logical error is a mistake in reasoning by the programmer, but it is not a mistake in the programming language. An example of a logical error would be dividing by 2.54 instead of multiplying to convert inches to centimeters.
Detailed explanation-3: -A logic error is an error in a program’s source code that gives way to unanticipated and erroneous behavior. A logic error is classified as a type of runtime error that can result in a program producing an incorrect output. It can also cause the program to crash when running.
There is 1 question to complete.