just a small error i can't seem to identify!

i've made a simple calculator prgram, add, sub, times and divide but there's a error i can't seem to identify, theres only the 1 can some one please identify it for me.

regards in advance simon

Program lesson4_Program1;
Uses Crt;
Label 1; {this is used with a goto statement}
Var Sel: String;
N1,N2, Total : Real;
YN : Char; {this is a character variable type,
which holds single characters ONLY}

begin
1:clrscr;
Total := 0; {always initialize integer/real cariable}
writeln('1:addition');
writeln('2:subtraction');
writeln('3:multiplication');
writeln('4:division');
writeln('5:exit');
write('select ');
Sel := readkey;
if Sel = '1' {action} then
begin {more than one statment}
clrscr;
write('input No1: ');
readln(N1);
write('input No1: ');
readln(N2);
Total := N1 + N2;
Writeln('Addition: ',N1:2:3,' + ',N2:2:3,' = ',Total:2:3);
write('press any key to continue...');
readkey;
Goto 1; {this leads back to the begining of the program other wise
the program terminates}
end;
if Sel = '2' then
begin
clrscr;
write('input No1: ');
readln(N1);
write('input No2: ');
readln(N2);
Total := N1 - N2; {subtraction}
write('subtraction:'N1:2:3,' - ',N2:2:3,' = ',Total:2:3);
write('press any key to continue...');
readkey;
goto 1;
end; {closing the if statment}

if Sel = '3' then
begin
clrscr;
write('input No1: ');
readln(N1);
write('input No2: ');
readln(N2);
Total := N1 * N2; {multiplication}
write('multiplicaton:'N1:2:3, ' * ',N2:2:3,' = ',Total:2:3);
write('press any key to continue....');
readkey;
goto 1;
end; {closing the if statement}

if Sel = '4' then
begin
clrscr;
write('input No1: ');
readln(N1);
write('input No2: ');
readln(N2);
Total := N1 / N2; {division}
write('division:'N1:2:3, ' / ',N2:2:3,' = ',Total:2:3);
write('press any key to continue...');
readkey;
goto 1;
end;
if Sel = '5' then
write('are you sure? (Y/N) ');
YN := readkey;
if YN = 'Y' then Halt; {1 action so no need of begin...end}
if YN = 'N' then goto 1;

end;
end.

Comments

  • : i've made a simple calculator prgram, add, sub, times and divide but there's a error i can't seem to identify, theres only the 1 can some one please identify it for me.
    :
    : regards in advance simon
    :
    : Program lesson4_Program1;
    : Uses Crt;
    : Label 1; {this is used with a goto statement}
    : Var Sel: String;
    : N1,N2, Total : Real;
    : YN : Char; {this is a character variable type,
    : which holds single characters ONLY}
    :
    : begin
    : 1:clrscr;
    : Total := 0; {always initialize integer/real cariable}
    : writeln('1:addition');
    : writeln('2:subtraction');
    : writeln('3:multiplication');
    : writeln('4:division');
    : writeln('5:exit');
    : write('select ');
    : Sel := readkey;
    : if Sel = '1' {action} then
    : begin {more than one statment}
    : clrscr;
    : write('input No1: ');
    : readln(N1);
    : write('input No1: ');
    : readln(N2);
    : Total := N1 + N2;
    : Writeln('Addition: ',N1:2:3,' + ',N2:2:3,' = ',Total:2:3);
    : write('press any key to continue...');
    : readkey;
    : Goto 1; {this leads back to the begining of the program other wise
    : the program terminates}
    : end;
    : if Sel = '2' then
    : begin
    : clrscr;
    : write('input No1: ');
    : readln(N1);
    : write('input No2: ');
    : readln(N2);
    : Total := N1 - N2; {subtraction}
    : write('subtraction:'N1:2:3,' - ',N2:2:3,' = ',Total:2:3);
    : write('press any key to continue...');
    : readkey;
    : goto 1;
    : end; {closing the if statment}
    :
    : if Sel = '3' then
    : begin
    : clrscr;
    : write('input No1: ');
    : readln(N1);
    : write('input No2: ');
    : readln(N2);
    : Total := N1 * N2; {multiplication}
    : write('multiplicaton:'N1:2:3, ' * ',N2:2:3,' = ',Total:2:3);
    : write('press any key to continue....');
    : readkey;
    : goto 1;
    : end; {closing the if statement}
    :
    : if Sel = '4' then
    : begin
    : clrscr;
    : write('input No1: ');
    : readln(N1);
    : write('input No2: ');
    : readln(N2);
    : Total := N1 / N2; {division}
    : write('division:'N1:2:3, ' / ',N2:2:3,' = ',Total:2:3);
    : write('press any key to continue...');
    : readkey;
    : goto 1;
    : end;
    : if Sel = '5' then
    : write('are you sure? (Y/N) ');
    : YN := readkey;
    : if YN = 'Y' then Halt; {1 action so no need of begin...end}
    : if YN = 'N' then goto 1;
    :
    : end;
    : end.
    :
    :
    What kind of error? Which message? Do you have an idea where about's the error happens, at the beginning/at the end of the program/certain inputs/etc?
  • it's erm something about fatal: syntax error, )expected but N1 found on line 41

  • : it's erm something about fatal: syntax error, )expected but N1 found on line 41
    :
    :
    Syntax error are always errors in the way you wrote your code. Appearantly the compiler expected to find a ")" symbol on line 41, and found a N1. Since I don't want to start counting lines in your posted code, you should only post line 41. The editor should show the cursor position somewhere on the screen.
  • : : it's erm something about fatal: syntax error, )expected but N1 found on line 41
    : :
    : :
    : Syntax error are always errors in the way you wrote your code. Appearantly the compiler expected to find a ")" symbol on line 41, and found a N1. Since I don't want to start counting lines in your posted code, you should only post line 41. The editor should show the cursor position somewhere on the screen.
    :
    heres line 41

    write('subtraction:'N1:2:3,' - ',N2:2:3,' = ',Total:2:3);
  • : : : it's erm something about fatal: syntax error, )expected but N1 found on line 41
    : : :
    : : :
    : : Syntax error are always errors in the way you wrote your code. Appearantly the compiler expected to find a ")" symbol on line 41, and found a N1. Since I don't want to start counting lines in your posted code, you should only post line 41. The editor should show the cursor position somewhere on the screen.
    : :
    : heres line 41
    :
    : write('subtraction:'N1:2:3,' - ',N2:2:3,' = ',Total:2:3);
    :
    You forgot a comma between subtraction and N1.
  • thnx dude, your were alot of help! i compiled it without any errors thanx 2 u. you have my thanks!
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories