COMPUTER PROGRAMMING FUNDAMENTALS
WHAT IS PROGRAMMING
Question
[CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
|
|
Variables
|
|
Loops
|
|
Conditionals
|
|
None of the above
|
Detailed explanation-1: -“If” statements: where if a condition is true it is used to specify execution for a block of code. “Else” statements: where if the same condition is false it specifies the execution for a block of code.
Detailed explanation-2: -If statement The condition is evaluated first before executing any statement inside the body of If. The syntax for if statement is as follows: if (condition) instruction; The condition evaluates to either true or false.
Detailed explanation-3: -The else statement With if statements, our programs can execute a set of instructions only if the condition is true. If we want our programs to execute a different set of instructions when the condition is false, then we can use an else statement.
Detailed explanation-4: -An if statement tells the program to execute a block of code, if a condition is true. In the code below, we output a message only if x is greater than 0: var x = 5; if (x > 0) text(’x is a positive number!’, 200, 200); Since x is 5, which is greater than 0, we would see the message on the canvas.