From the course: Complete Guide to C Programming Foundations
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Chapter challenge: Interpreting commands - C Tutorial
From the course: Complete Guide to C Programming Foundations
Chapter challenge: Interpreting commands
(upbeat music) - [Instructor] You've been tasked with writing a command interpreter for a text mode video game. Here's the program running in this window. The solution for this challenge, the program outputs a prompt command. If the user doesn't know what to type, they can type a question mark and then they can see which commands they can type. So you can go right, you can go left, or you can go back. I've even written into the code that you can type in full words such as, RIGHT and in lowercase and unknown commands are also dealt with. Type Q to quit. Here's the code skeleton to get you started. Variable declarations go here. The program spins in this while loop where the condition is the value of variable done. It's initially set to false at line 12. You must add statements to prompt for input. Process the input, then evaluate the results, outputting the messages as shown earlier. Here are the details. Convert the double slash comments in the challenge exercise file into C language…
Contents
-
-
-
-
-
-
Making a decision3m 25s
-
(Locked)
Exploring the possibilities2m 53s
-
(Locked)
Using the ternary operator3m
-
Working with the switch-case structure4m
-
(Locked)
Challenge: Select an item28s
-
(Locked)
Solution: Select an item1m 45s
-
Creating a for loop3m 36s
-
(Locked)
Setting up a while loop2m 58s
-
(Locked)
Challenge: Repeat some text51s
-
(Locked)
Solution: Repeat some text1m 51s
-
(Locked)
Nesting loops1m 59s
-
(Locked)
Breaking out of a loop3m 16s
-
(Locked)
Avoiding the goto keyword1m 33s
-
(Locked)
Chapter challenge: Interpreting commands2m 26s
-
(Locked)
Chapter solution: Interpreting commands3m 55s
-
-
-
-
-
-
-
-