Recent

Author Topic: missed semicolon.  (Read 4373 times)

angel208

  • Newbie
  • Posts: 2
missed semicolon.
« on: May 06, 2014, 06:03:26 pm »
hello. I've got an assignment on my yesterday class. i need to make a program that reads characters and if they are (1,2,3,4), the program will show (a,b,c,d) respectively. the teacher specified that it need to be done using a function. when i "finished", the compiler gave me an error because it was a semicolon missed before the end of the program, but no matter how much i try to fix it, it keeps giving that error. i would appreciate if you guys could help me. my code until now is:

Code: [Select]
program funcion;
uses crt;
var num: char;

Function search(a:char): char;

Begin
 case a of '1':
   search:='a';
 '2':
   search:='b';
 '3':
   search:='c';
end;


begin
writeln ('type in a character');
readln (num);

writeln (search(num));

end.

i would appreciate any help with the code. (sorry for my grammar, my mother language is Spanish).

engkin

  • Hero Member
  • *****
  • Posts: 2513
Re: missed semicolon.
« Reply #1 on: May 06, 2014, 06:18:27 pm »
You need to close your case statement with an end

Quote
Function search(a:char): char;

Begin
 case a of '1':
   search:='a';
 '2':
   search:='b';
 '3':
   search:='c';
  end;  //<----- is missing
end;

angel208

  • Newbie
  • Posts: 2
Re: missed semicolon.
« Reply #2 on: May 06, 2014, 06:20:37 pm »
wow, thank you  for the fast response. that was exactly the problem. thank you very much