COMPUTER FUNDAMENTALS

COMPUTER NETWORKS AND COMMUNICATIONS

NETWORK SECURITY AND CYBERSECURITY

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
How can we improve the following program?function start() { move(); move(); move(); move(); move(); move(); move(); move(); move();}
A
Break down this program into more functions
B
Use a for loop to repeat the move command
C
Use a while loop to repeat the move command
D
Fix the indentation of this program
Explanation: 

Detailed explanation-1: -As it turns out, there is a way for Karel to make right turns. Karel can “turn right” by turning left three times. Three lefts make a right!

Detailed explanation-2: -A command is an instruction you can give to Karel. For example, if you give the command move(); , Karel will move forward one space in the current direction.

Detailed explanation-3: -We can teach Karel new commands using functions. We’ve seen that Karel already knows four commands, or functions. Now we want to teach Karel a new command, turnRight() . We can teach Karel to turn right by defining a function called turnRight() that shows Karel how to turn to the right.

Detailed explanation-4: -Functions are used to teach Karel a word or command. Using functions allow us to break down our program into smaller pieces and make it easier to understand.

There is 1 question to complete.