icp/oer/courses/c-basics/sections/02-basic-language-features/05-switch/program.c

28 lines
679 B
C

#include<stdio.h>
int main(int argc, const char *argv[])
{
char String[] = "1453g5a24";
char *At = String;
while(*At)
{
char c = *At;
// Complete this Switch-Statement to print out the numbers to 5 in words
// Characters should just be printed out as is. (use the default keyword instead of the case keyword)
// Also fix the bug that is already in the code.
switch(c) // This defines the expression we are going to switch on.
{
case '1': // The case keywords defines the starting point for code execution
{
printf("One ");
}
case '2':
{
printf("Two ");
}break; // The break stops the program to execute the next case
}
At++;
}
}