Solutions TOPIC C: Characters

Contents :

Integer, + - * DIV MOD, IF, FOR, WHILE, RdInt, WrInt.

Exercises :


D1

Exercise

MODULE D1;
<* NOOPTIMIZE + *>
    FROM IO IMPORT RdChar, RdKey, WrChar, WrStr, WrLn, RdStr, RdLn, WrCard;     (* import general procedures *)

    CONST STRING_SIZE = 10;          (* constants *)

    VAR a: CHAR;         (* variable-declarations *)
        word: ARRAY[1..STRING_SIZE] OF CHAR;
        i : CARDINAL;
BEGIN
    WrLn;
    WrStr("Please give me a character: ");
    a := RdChar();
    WrLn;
    WrStr("Please give me a word of max 10 characters: ");
    RdStr(word);
    WrLn;

    (* check *)
    IF (word[2] = 'a') OR (word[2] = 'e') OR (word[2] = 'i')  OR (word[2] = 'u')  OR (word[2] = 'o') THEN
      word[2] := a;  (* note the difference between the letter 'a' and the variable a !!*)
    END;

    (* print word *)
    WrStr("This is your word: ");
    WrStr(word);
    WrLn;

END D1.


S1

Exercise
 


S2

Exercise
 


S3

Exercise
 


X1

Exercise
 


H1

Exercise
 


H2

Exercise
 


T1

Exercise


Back to the top -- Back to exercises index

Signal an error or a mistake