Created
July 17, 2018 13:12
-
-
Save peterooch/ce1c195786fc4dd1e2a19617064784bd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main() | |
{ | |
int x; | |
char dummy; | |
char* months[] = { | |
"January", | |
"February", | |
"March", | |
"April", | |
"May", | |
"June", | |
"July", | |
"August", | |
"September", | |
"October", | |
"November", | |
"December" | |
}; | |
scanf_s("%d%c", &x, &dummy); | |
if (x > 12 || x <= 0) | |
{ | |
printf("%s", "Error"); | |
getchar(); | |
getchar(); | |
return 0; | |
} | |
printf("%s", months[x - 1]); | |
getchar(); | |
getchar(); | |
return 1; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main() | |
{ | |
int x; | |
char dummy; | |
char* morse[] = { | |
"-----", | |
".----", | |
"..---", | |
"...--", | |
"....-", | |
".....", | |
"-....", | |
"--...", | |
"---..", | |
"----.", | |
}; | |
while (1) | |
{ | |
printf("%s", "Dial a digit\n"); | |
scanf_s("%d", &x); | |
if (x == 99) | |
return 1; | |
if (x > 9 || x < 0) | |
{ | |
printf("%s", "Error\n"); | |
getchar(); | |
continue; | |
} | |
printf("%s\n", morse[x]); | |
getchar(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment