Code:
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <string.h>
Struct Soldier
{
int age;
char name [20];
char sex [10];
// F for the woman, M for the man
} s1, s2;
int main ()
{
printf ("\ nFirst Soldier \ n");
// Enter the name of the first soldier
printf ("Enter name:");
scanf ("% s", s1.name);
// Enter the age of the first soldier
printf ("Enter age:");
scanf ("% d", & s1.varsta);
// Enter the sex of the first soldier
printf ("Enter sex:");
scanf ("% s", s1.sex);
printf ("The Second Soldier! \ n");
// Enter the name of the second soldier
printf ("Enter name:");
scanf ("% s", s2.name);
// Enter the age of the second soldier
printf ("Enter age:");
scanf ("% d", & s2.varsta);
// Enter the sex of the second soldier
printf ("Enter sex:");
scanf ("% s", s2.sex);
int i, j;
char l [37] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h' , 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',' t ',' u ',' v ',' w ',' x ',' y ',' z ',' 1 ',' 2 ',' 3 ',' 4 ',' 5 ',' 6 ',' 7 ',' 8 ',' 9 ',' 0 ' , ''};
char m [37] [6] = {{".-"}, {"-..."}, {"- "" - "-" - "" - "" - "-" - '.- .. "}, {" - "}, {" -. "}, {" --- "}, {" .. "}, {" --.- "}, {" , "", "", "" - "}, {" ..- "}, {" ...- "}, {". - "}, {" -.-- "}, {" - .. "}, {" .---- "}, {" ..--- "}, {" ...-- " }, { "....-"}, { "....."}, { "-...."}, { "--..."}, { "--- .." }, { "----."}, { "-----"}, { "//"}};
char k [10000];
printf ("Write the message from Soldier 1 for Soldier 2: \ n");
gets (k);
for (i = 0; i <k [i]; i ++)
for (j = 0; j <37; j ++)
if (k [i] == l [j])
printf ( "% s", m [j]);
getch ();
{
printf ("The name of the Soldier 1:% s \ n", s1.name);
printf ("\ nThe Age of Soldier 1:% d \ n", s1.varsta);
printf ("\ nSex of Soldier 1:% s \ n", s1.sex);
printf ("\ nNumber of Soldier 2:% s \ n", s2.name);
printf ("\ nThe Age of Soldier 2:% d \ n", s2.varsta);
printf ("\ nSex of Soldier 2:% s \ n", s2.sex);
}
return 0;
}