Skip to content

Instantly share code, notes, and snippets.

@peterooch
Created July 17, 2018 13:12
Show Gist options
  • Save peterooch/ce1c195786fc4dd1e2a19617064784bd to your computer and use it in GitHub Desktop.
Save peterooch/ce1c195786fc4dd1e2a19617064784bd to your computer and use it in GitHub Desktop.
#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;
}
#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