stkapler 0 / 0 / 0 Регистрация: 07.02.2018 Сообщений: 19 |
||||
1 |
||||
07.02.2018, 04:52. Показов 22831. Ответов 14 Метки delphi, lazarus, pascal (Все метки)
звучит задание: создай программу, в которой можно преподнести введенное пользователем число к указанному степеню. покапавшись на всяких форумах и тп, написал код. вроде бы все ок. но при компиляции выдает ошибку в 41 строке unit1.pas(42,17) Fatal: Syntax error, «;» expected but «.» found ниже код:
ps. уже сам нашел несколько ошибок, но все равно проблема осталась Добавлено через 8 минут
__________________
0 |
Programming Эксперт 94731 / 64177 / 26122 Регистрация: 12.04.2006 Сообщений: 116,782 |
07.02.2018, 04:52 |
Ответы с готовыми решениями: Ошибка «project1.lpr(35,0) Fatal: Syntax error, «BEGIN» expected but «end of file» found» Ошибка: project1.lpr(1,1) Fatal: Syntax error, «BEGIN» expected but «end of file» found Ошибка: Fatal: Syntax error, «;» expected but «identifier Mas» found. procedure TForm1.Button1Click(Sender: TObject); Ошибка Fatal: Syntax error, «;» expected but «is» found 14 |
Джоуи 1073 / 635 / 240 Регистрация: 05.05.2015 Сообщений: 3,546 Записей в блоге: 2 |
|
07.02.2018, 05:48 |
2 |
implementation function Power(const Base, Exponent: Extended): Extended; Директива implementation означает раздел реализации, а не описания. Вы не реализовали функцию Power, а просто ее описали (нету begin end). Кстати, переименуйте как-нибудь, а то функция Power уже есть в паскале
0 |
Модератор 8257 / 5480 / 2249 Регистрация: 21.01.2014 Сообщений: 23,584 Записей в блоге: 3 |
|||||
07.02.2018, 06:04 |
3 |
||||
НЕ ЗНАЮ ЧТО ДЕЛАТЬ!
3. В секции uses подключить модуль Math
0 |
stkapler 0 / 0 / 0 Регистрация: 07.02.2018 Сообщений: 19 |
||||
07.02.2018, 12:22 [ТС] |
4 |
|||
сделал все как вы сказали unit1.pas(39,25) Error: Incompatible type for arg no. 1: Got «TTranslateString», expected «Int64» unit1.pas(39,25) Error: Incompatible type for arg no. 1: Got «TTranslateString», expected «Int64» сами строки
у меня есть готовый ответ на это задание, даже 2. но все таки хочу найти решение самостоятельно, пусть даже при помощи форумчан)
0 |
Модератор 8257 / 5480 / 2249 Регистрация: 21.01.2014 Сообщений: 23,584 Записей в блоге: 3 |
|
07.02.2018, 12:35 |
5 |
stkapler, Вы Добавлено через 7 минут
0 |
0 / 0 / 0 Регистрация: 07.02.2018 Сообщений: 19 |
|
07.02.2018, 12:36 [ТС] |
6 |
все хорошо, спасибо! проект компилируется и запускается НО!! при вводе чисел и после нажатия кнопки — ничего не происходит. а должен быть результат visible включен. шрифт норм, цвет отличный от фона. ничего не понимаю
0 |
Модератор 8257 / 5480 / 2249 Регистрация: 21.01.2014 Сообщений: 23,584 Записей в блоге: 3 |
|
07.02.2018, 12:41 |
7 |
А Вы этот обработчик
0 |
0 / 0 / 0 Регистрация: 07.02.2018 Сообщений: 19 |
|
07.02.2018, 12:43 [ТС] |
8 |
нет, не создавал
0 |
Модератор 8257 / 5480 / 2249 Регистрация: 21.01.2014 Сообщений: 23,584 Записей в блоге: 3 |
|
07.02.2018, 14:48 |
9 |
РешениеНе по теме:
А Вы этот обработчик создавали
нет, не создавал но в планах для красивого оформления программы это есть :scratch: stkapler, возьмите любую книжку по самым-самым азам создания программ в среде Delphi/Lazarus и обязательно прочтите ее… Ну или программирование бросайте прямо сейчас…
0 |
0 / 0 / 0 Регистрация: 07.02.2018 Сообщений: 19 |
|
07.02.2018, 19:11 [ТС] |
10 |
спасибо, теперь все ок!
0 |
Hretgir |
07.02.2018, 20:01
|
Не по теме:
зачем в 2018 дают учить паскаль действительно, ребята учатся на начальников Била Гейтса, а их Паскаль учить заставляют, маразм да и только.
0 |
0 / 0 / 0 Регистрация: 07.02.2018 Сообщений: 19 |
|
07.02.2018, 20:08 [ТС] |
12 |
орнул. ну считайте что у меня узкое мировоззрение, ваше право
0 |
Hretgir |
07.02.2018, 20:37
|
Не по теме: а что-бы вы хотели учить в 2018? просто интересно…
0 |
stkapler |
07.02.2018, 20:58 [ТС] |
Не по теме: я себе сейчас спокойно учу видеомонтаж в свое свободное время, но учить паскаль — навязывает школьная программа
0 |
Cyborg Drone |
08.02.2018, 09:25
|
Не по теме: Да не спорьте. Не нужно знать язык программирования — значит, не нужно. Личное дело каждого. С другой стороны, те, кто всерьёз занимается программированием, как правило, знает несколько языков программирования, и выучить ещё один, как правило, никакая не проблема.
0 |
IT_Exp Эксперт 87844 / 49110 / 22898 Регистрация: 17.06.2006 Сообщений: 92,604 |
08.02.2018, 09:25 |
Fatal: Syntax error, «BEGIN» expected but «end of file» found Unit1.pas(41,5) Fatal: Syntax error, «;» expected but «identifier Y» found
Unit1.pas(66,4) Fatal: Syntax error, «;» expected but «.» found {$mode objfpc}{$H+} interface uses Искать еще темы с ответами Или воспользуйтесь поиском по форуму: 15 |
Topic: problem with Fatal: Syntax error, «;» expected but «:» found (Read 5271 times)
Hello, I am a beginner in Lazarus and the Pascal language.
my problem is that every time I try to run my program it gives me this error: Fatal: syntax error, «;» expected but found.
in case there is any doubt this is the program.
program division;
var
a,b,c:double;
begin
writeln(‘extra division’);
writeln(‘ingresa el divisor’);
readln(a);
writeln(‘ingresa el dividendo’);
readln(b);
if (b=0) then
begin
writeln(‘math error’);
readln;
end
else
begin
c:a/b;
writeln(‘el resultado de la division es’,c:4:2);
readln;
end;
I would be very grateful to you if you could help me solve this problem.
Logged
Logged
HOMEWORK ???
-
PROGRAM Division;
-
VAR dDividend,dDivisor,dQuotient:Double;
-
BEGIN
-
Writeln(‘extra division’);
-
Writeln(‘ingresa el dividendo’);
-
Readln(dDividend);
-
Writeln(‘ingresa el divisor’);
-
Readln(dDivisor);
-
If (dDivisor = 0)
-
Then
-
Begin
-
Writeln(‘math error’);
-
Readln;
-
End
-
Else
-
Begin
-
dQuotient:= dDividend/dDivisor;
-
Writeln(‘el resultado de la division es: ‘,dQuotient:4:2);
-
Readln;
-
END;
-
END.
Logged
Windows 7 Pro (x64 Sp1) & Windows XP Pro (x86 Sp3).
Logged
Hello, I am a beginner in Lazarus and the Pascal language.
my problem is that every time I try to run my program it gives me this error: Fatal: syntax error, «;» expected but found.
in case there is any doubt this is the program.
program division;
var
a,b,c:double;
begin
writeln(‘extra division’);
writeln(‘ingresa el divisor’);
readln(a);
writeln(‘ingresa el dividendo’);
readln(b);
if (b=0) then
begin
writeln(‘math error’);
readln;
end
else
begin
c:a/b;
writeln(‘el resultado de la division es’,c:4:2);
readln;
end;I would be very grateful to you if you could help me solve this problem.
Logged
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
———————————————————————
Code is like a joke: If you have to explain it, it’s bad
This line:
-
c:a/b;
Needs to be changed to this:
-
c := a/b;
Also, you need to add the following at the bottom of the file to close your 1st ‘begin’ and the unit as a whole:
-
end.
So, the entire code should look like this:
-
program division;
-
var
-
a, b, c : double;
-
begin
-
WriteLn(‘extra division’);
-
WriteLn(‘ingresa el divisor’);
-
ReadLn(a);
-
WriteLn(‘ingresa el dividendo’);
-
ReadLn(b);
-
if (b=0) then
-
begin
-
WriteLn(‘math error’);
-
ReadLn;
-
end
-
else
-
begin
-
c := a / b; // <— CHANGED!!!
-
WriteLn(‘el resultado de la division es’, c:4:2);
-
ReadLn;
-
end;
-
end. // <— ADDED!!!
« Last Edit: June 19, 2020, 08:31:39 pm by Remy Lebeau »
Logged
@Remy Lebeau: almost … one is missing …
You don’t get the flower pot !
Logged
Windows 7 Pro (x64 Sp1) & Windows XP Pro (x86 Sp3).
@Remy Lebeau: almost … one is missing …
Which one? I don’t see anything missing in the code I posted.
Logged
I don’t see anything missing in the code I posted.
Correct, nothing is missing, but the «WriteLn» order is not optimal…
Divisor (a), Dividend (b), Check b = 0 (Dividend?), Divisor/Dividend ?
In my world you have to do it like this:
Dividend / Divisor = Quotient
As I said, you don’t get the flower pot …
Logged
Windows 7 Pro (x64 Sp1) & Windows XP Pro (x86 Sp3).
Hi!
Dont battle about the poor dividende.
We could teach him the way the C boys do it:
Division by zero is no error. Never.
SetExceptionMask([exZeroDivide, exInvalidOp, exDenormalized, exOverflow, exUnderflow, exPrecision]);
….
You dont have to ask for dividing by zero anymore.
The price you have to pay:
Incorrect results and a system crash every now and then.
We all know that from Windows.
Winni
Logged
Dont battle about the poor dividende.
We could teach him the way the C boys do it:
Division by zero is no error. Never.
I think RAW is referring just to the terminology in the WriteLn’s: Remy’s code asks for the divisor when he means the dividend and viceversa. Just a small oversight
Logged
Turbo Pascal 3 CP/M — Amstrad PCW 8256 (512 KB !!!)
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 — 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.
…code asks for the divisor when he means the dividend and viceversa…
@lucamar: the flowers are all yours …
by the way: no battle at all, just a little hint that the code isn’t optimal …
Logged
Windows 7 Pro (x64 Sp1) & Windows XP Pro (x86 Sp3).
I think RAW is referring just to the terminology in the WriteLn’s: Remy’s code asks for the divisor when he means the dividend and viceversa. Just a small oversight
It is not MY code, it is the OP’s code. I just fixed the syntax errors, not the logic errors.
Logged
Иван Шихалев писал(а):Судя по всему, пути поиска не указаны, или кривые. Что в fpc.cfg?
#
# Example fpc.cfg for Free Pascal Compiler
#
# ———————-
# Defines (preprocessor)
# ———————-
#
# nested #IFNDEF, #IFDEF, #ENDIF, #ELSE, #DEFINE, #UNDEF are allowed
#
# -d is the same as #DEFINE
# -u is the same as #UNDEF
#
#
# Some examples (for switches see below, and the -? helppages)
#
# Try compiling with the -dRELEASE or -dDEBUG on the commandline
#
# For a release compile with optimizes and strip debuginfo
#IFDEF RELEASE
-O2
-Xs
#WRITE Compiling Release Version
#ENDIF
# For a debug version compile with debuginfo and all codegeneration checks on
#IFDEF DEBUG
-g
-Crtoi
#WRITE Compiling Debug Version
#ENDIF
# set binutils prefix
#IFNDEF CPUI386
#IFNDEF CPUAMD64
#DEFINE NEEDCROSSBINUTILS
#ENDIF
#ENDIF
#IFNDEF linux
#DEFINE NEEDCROSSBINUTILS
#ENDIF
#IFDEF FPC_CROSSCOMPILING
#IFDEF NEEDCROSSBINUTILS
-XP$fpctarget-
#ENDIF NEEDCROSSBINUTILS
#ENDIF
# assembling
#ifdef darwin
# use pipes instead of temporary files for assembling
-ap
#endif
# —————-
# Parsing switches
# —————-
# Pascal language mode
# -Mfpc free pascal dialect (default)
# -Mobjfpc switch some Delphi 2 extensions on
# -Mdelphi tries to be Delphi compatible
# -Mtp tries to be TP/BP 7.0 compatible
# -Mgpc tries to be gpc compatible
# -Mmacpas tries to be compatible to the macintosh pascal dialects
#
# Turn on Object Pascal extensions by default
#-Mobjfpc
# Assembler reader mode
# -Rdefault use default assembler
# -Ratt read AT&T style assembler
# -Rintel read Intel style assembler
#
# All assembler blocks are AT&T styled by default
#-Ratt
# Semantic checking
# -S2 same as -Mobjfpc
# -Sc supports operators like C (*=,+=,/= and -=)
# -Sa include assertion code.
# -Sd same as -Mdelphi
# -Se<x> error options. <x> is a combination of the following:
# <n> : compiler stops after the <n> errors (default is 1)
# w : compiler stops also after warnings
# n : compiler stops also after notes
# h : compiler stops also after hints
# -Sg allow LABEL and GOTO
# -Sh Use ansistrings
# -Si support C++ styled INLINE
# -Sk load fpcylix unit
# -SI<x> set interface style to <x>
# -SIcom COM compatible interface (default)
# -SIcorba CORBA compatible interface
# -Sm support macros like C (global)
# -So same as -Mtp
# -Sp same as -Mgpc
# -Ss constructor name must be init (destructor must be done)
# -St allow static keyword in objects
# -Sx enable exception keywords (default in Delphi/ObjFPC modes)
#
# Allow goto, inline, C-operators, C-vars
-Sgic
# —————
# Code generation
# —————
# Uncomment the next line if you always want static/dynamic units by default
# (can be overruled with -CD, -CS at the commandline)
#-CS
#-CD
# Set the default heapsize to 8Mb
#-Ch8000000
# Set default codegeneration checks (iocheck, overflow, range, stack)
#-Ci
#-Co
#-Cr
#-Ct
# Optimizer switches
# -Os generate smaller code
# -O1 level 1 optimizations (quick optimizations, debuggable)
# -O2 level 2 optimizations (-O1 + optimizations which make debugging more difficult)
# -O3 level 3 optimizations (-O2 + optimizations which also may make the program slower rather than faster)
# -Op<x> set target cpu for optimizing, see fpc -i for possible values
#
# See «fpc -i» also for more fine-grained control over which optimizations
# to perform
#ifdef darwin
#ifdef cpui386
-Cppentiumm
-Oppentiumm
#endif
#endif
# ————————
# Set Filenames and Paths
# ————————
# Slashes are also allowed under dos
# path to the messagefile, not necessary anymore but can be used to override
# the default language
#-Fr/usr/lib/fpc/$fpcversion/msg/errore.msg
#-Fr/usr/lib/fpc/$fpcversion/msg/errorn.msg
#IFDEF FPCAPACHE_1_3
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/httpd13/
#ELSE
#IFDEF FPCAPACHE_2_0
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/httpd20
#ELSE
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/httpd22
#ENDIF
#ENDIF
# searchpath for units and other system dependent things
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/*
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/rtl
#-Fu~/fpc/packages/base/*/units/;~/fpc/fcl/units/;~/fpc/rtl/units/
# searchpath for libraries
#ifdef cpux86_64
-Fl/usr/lib/gcc/x86_64-linux-gnu/4.4.5
#endif
#ifdef cpui386
-Fl/usr/lib/gcc/x86_64-linux-gnu/4.4.5
#endif
#-Fl/pp/lib
#-Fl/lib;/usr/lib
# ————-
# Linking
# ————-
# generate always debugging information for GDB (slows down the compiling
# process)
# -gc generate checks for pointers
# -gd use dbx
# -gg use gsym
# -gh use heap trace unit (for memory leak debugging)
# -gl use line info unit to show more info for backtraces
# -gv generates programs tracable with valgrind
# -gw generate dwarf debugging info
#
# Enable debuginfo and use the line info unit by default
#-gl
# always pass an option to the linker
#-k-s
# Always strip debuginfo from the executable
-Xs
# ————-
# Miscellaneous
# ————-
# Write always a nice FPC logo
-l
# Verbosity
# e : Show errors (default) d : Show debug info
# w : Show warnings u : Show unit info
# n : Show notes t : Show tried/used files
# h : Show hints c : Show conditionals
# i : Show general info d : Show debug info
# l : Show linenumbers r : Rhide/GCC compatibility mode
# a : Show everything x : Executable info (Win32 only)
# b : Write file names messages with full path
# v : write fpcdebug.txt with p : Write tree.log with parse tree
# lots of debugging info
#
# Display Info, Warnings and Notes
-viwn
# If you don’t want so much verbosity use
#-vw
#
# That’s all folks
#
- Печать
Страницы: [1] Вниз
Тема: Помогите зеленому с паскалем. (Прочитано 4215 раз)
0 Пользователей и 1 Гость просматривают эту тему.

wannabebrucelee
В общем в универе ща паскаль проходят, хочу познать его на уровне решения лаб , но есть проблема. У меня чёт не получается настоить инструменталий или я чёто не то делаю.
В общем ubuntu 9.10, на неё поставил Lazarus.
В source editor пишу:
program hello;
var
i;
begin
i := 0;
WriteLn(i);
Write (‘Hello’);
ReadLn;
end.
Потом нажимаю на зелёную стрелку и вылазит сообщение: unit1.pas(1,1) Fatal: Syntax error, «UNIT» expected but «PROGRAM» found
Что я делаю не так ( чую, что я всё делаю не так…), Но просто никогда не пользовался подобными программами. Я просто боле мене знаком с вебом(php, css) и там всё совсем по другому.
В общем помогите глупому быдлокодеру разобраться с инструменталием.

MaSsoL
Может тип переменной объявить?

jef

wannabebrucelee
program hello;
var
i: Word;
begin
i:= 0;
WriteLn(i);
Write(‘Hello’);
ReadLn;
end.
вроде так.
Так?)
Ну это всё тоже самое выдаёт и получается.

wl
Учите Паскаль, все же придется это сделать.
Разберитесь чем unit отличается от program.
unit1.pas(1,1) Fatal: Syntax error, «UNIT» expected but «PROGRAM» found
unit (модуль) — это библиотека функций и классов, а program — это программа.
Модулей в программе может быть много, но точка входа в исполняемый код всего одна, и она в программе.
Я никогда не программировал в лазарусе, а паскаль еще 10 лет назад в институте забыл как страшный сон.
Но думаю, что там надо организовать проект, дать возможность отработать визардам, чтобы компилятор получил на вход правильную команду.
Возможно, лазарус — это стрельба из пушки по воробьям, и в Вашем случае достаточно будет free pascal и текстового редактора с подсветкой синтаксиса.
На свете феньки есть такие, брат Горацио, которых лохи просто не секут. (Шекспир, «Гамлет», вольный перевод)

wannabebrucelee
А как free pascal установить? Просто через поиски выдаёт на лазарус в основном и на ссылки, где я мало чё понимаю. И блокнот с подстветкой синстаксиса как установить? Пожалуйста, направьте на путь истинный.

Protopopulus
Синтаксис подсвечивается в стандартном gedit.
Установить — sudo apt-get install fpc (в терминале)
Если ты владеешь знаниями, то и знания владеют тобой. (с) Protopopulus

wannabebrucelee
rm -rf ~/fpcinstall
mkdir ~/fpcinstall
cd ~/fpcinstall
wget ftp://ftp.chg.ru/pub/lang/pascal/fpc/dist/2.4.0/i386-linux/deb/*.deb
dpkg-scanpackages ./ | gzip -c9 > Packages.gz
grep «deb file:///$HOME/fpcinstall/ /» /etc/apt/sources.list || sudo echo «deb file:///$HOME/fpcinstall/ /» >> /etc/apt/sources.list
sudo apt-get update
sudo apt-get install fpc
Я вот чё в нете ща нашёл, и установил, это нормально? Я ничё не наворочил?
Ну вот я пишу код в gedit а потом куда и что мне сохранять? в каком формате? И как выводить результат работы прграммы?

Protopopulus
Нормально все установил, молодец.
А по поводу написания… Сохраняешь в любой текстовый (plain-text) документ, можешь даже с расширением pas. А потом с терминала компилякаешь его:
fpc -TLINUX /path/to_document
Потом запускаешь:
/path_to/program
Программа будет иметь название исходного файла минус расширение .pas и лежать в той же директории, что и исходник.
Если ты владеешь знаниями, то и знания владеют тобой. (с) Protopopulus

wannabebrucelee
спасибо, пока вроде всё работает, ну я ещё обращусь, если чё)
- Печать
Страницы: [1] Вверх
Содержание
- Pascal fatal error «;» expected but else founded
- 2 Answers 2
- [Паскалъ] Need Help
- Fatal: Syntax error, «.» expected but «;» found
- 1 Answer 1
- Fatal syntax error expected but else found
- Re: Ошибка в коде программы!
- Re: Ошибка в коде программы!
- Re: Ошибка в коде программы!
- Re: Ошибка в коде программы!
- Re: Ошибка в коде программы!
- Re: Ошибка в коде программы!
- Re: Ошибка в коде программы!
Pascal fatal error «;» expected but else founded
What is causing the fatal error «;» expected but else founded message?
2 Answers 2
Unlike C, in Pascal a semicolon ; separates statements, it does not terminate them, and the then clause requires a single statement. then WriteLn(. ); else is two statements; you want then WriteLn(. ) else .
Let’s take this opportunity to learn how to read and use error messages to your advantage.
The compiler tells you exactly what the error is (it’s a ; before an else , because both of those are mentioned in the error message). It also gives you the exact line number where it’s reporting the error; that’s the number (usually in parentheses right before the error message, like (from Delphi):
[DCC Error] Project2.dpr(14): E2153 ‘;’ not allowed before ‘ELSE’
So the error is happening on line 14 (in my code — your number will be different). Let’s look at that line and a few before and after:
So look at the error message:
That clearly tells you that the ; in the line before the else is the problem (that’s very clear, because it says not allowed), so remove it.
BTW, now you’re going to get another error:
[DCC Error] Project2.dpr(15): E2003 Undeclared identifier: ‘wrtieln’
I think you should be able to figure that one out; again, the compiler gives you the exact line number.
You’re going to get another one, if you’ve posted your entire code:
[DCC Error] Project2.dpr(18): E2029 Statement expected but end of file found
This is because you’ve left out the end. that marks the end of a program file in Pascal. If you’ve not posted your entire code, you may not get it.
It’s important to learn to actually read the words when you get an error message from the compiler. In most languages, the messages are clearly worded, and they all have information you can use to try to figure out (or at least narrow down) the problems in your code.
Источник
[Паскалъ] Need Help
Что программа должна делать(на пхп)
ЕМНИП перед else там точка с запятой не ставится.
Не, ругается на другое, и спасибо это пофиксил.
> перед else там точка с запятой не ставится.
> ругается на другое
Условия в скобки попробуй.
Перед else ; не ставится.
У readln точно такой синтаксис? (я уже запамятовал)
Условия в скобки не надо?
Операции сравнения в скобки возьми.
А теперь, дружище, запомни, что вот этот выхлоп
untitled.pas(26,7) Error: Incompatible types: got «Boolean» expected «LongInt»
untitled.pas(28,2) Fatal: Syntax error, «;» expected but «ELSE» found
должен читать ТЫ сам, а не ЛОР.
Свободно говорю на Русском, Литовском, Английском.
Свободно говорю на Английском
Error: Incompatible types: got «Boolean» expected «LongInt»
Fatal: Syntax error, «;» expected but «ELSE» found
Источник
Fatal: Syntax error, «.» expected but «;» found
1 Answer 1
The reason for this is that your begin s and end s are not balanced; disregarding the opening begin and closing end. for the program’s syntax to be correct, you should have equal numbers of each, but you have 4 begin s and 8 end s.
Obviously, your code is to compute the solutions of a quadratic equation. What I think you should do is to adjust the layout of your code so that it reflects that and then correctly the begin s and end s. In particular, your program is trying to detect whether any of a, b and d is zero and, if so, write a diagnostic message, otherwise calculate the roots by the usual formula.
Unfortunately, your begin s and end s do not reflect that. Either the whole of the block starting d := . needs to be executed or none of it does, so the else on the line before needs to be followed by a begin , as in
(You don’t say which Pascal compiler you are using, but the above fixes two points which are flagged as errors in FreePascal.
If you need more help than that, please ask in a comment.
Btw, there are some grammatical constructs in Pascal implementations where an end can appear without a matching preceding begin such as case . of . end .
Источник
Fatal syntax error expected but else found
Анна Бак » 27.10.2014 17:40:51
Re: Ошибка в коде программы!
Дож » 27.10.2014 18:07:56
Видимо, проблема в том, что Вы отсканировали текст и не почистили от фигни.
Вместо короткого тире − должен знак минус -,
вместо обратной кавычки ’ — знак апострофа ‘.
Re: Ошибка в коде программы!
Анна Бак » 27.10.2014 20:02:42
Дож писал(а): Видимо, проблема в том, что Вы отсканировали текст и не почистили от фигни.
Вместо короткого тире − должен знак минус -,
вместо обратной кавычки ’ — знак апострофа ‘.
Я отсканировала текст только для того, чтобы задать вопрос.
А в Free Pascal вводила все в ручную и все знаки переписывала уже несколько раз, ничего не помогает.
Re: Ошибка в коде программы!
Little_Roo » 27.10.2014 20:40:10
Re: Ошибка в коде программы!
Анна Бак » 27.10.2014 21:35:18
Re: Ошибка в коде программы!
Little_Roo » 27.10.2014 21:38:27
Re: Ошибка в коде программы!
Анна Бак » 27.10.2014 22:11:59
Re: Ошибка в коде программы!
Дож » 27.10.2014 23:28:21
Дож писал(а): Видимо, проблема в том, что Вы отсканировали текст и не почистили от фигни.
Вместо короткого тире − должен знак минус -,
вместо обратной кавычки ’ — знак апострофа ‘.
Я отсканировала текст только для того, чтобы задать вопрос.
А в Free Pascal вводила все в ручную и все знаки переписывала уже несколько раз, ничего не помогает.
Источник