-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathmorse_code.cpp
More file actions
48 lines (43 loc) · 771 Bytes
/
Copy pathmorse_code.cpp
File metadata and controls
48 lines (43 loc) · 771 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <stdio.h>
main(){
char morse[26][5]={
".-",
"-...",
"-.-.",
"-..",
".",
"..-.",
"--.",
"....",
"..",
".---",
"-.-",
".-..",
"--",
"-.",
"---",
".--.",
"--.-",
".-.",
"...",
"-",
"..-",
"...-",
".--",
"-..-",
"-.--",
"--.."};
char str[100];
int n;
printf("Insert your word to convert: \n");
scanf("%s",str);
n=strlen(str);
for (int i=0;i<n;i++){
char c=str[i];
if (c>='a' && c<='z')
c=toupper(c);
if (c>='A' && c<='Z')
printf("%s ", morse[c-'A']);
}
printf("\n");
}