| | |
May I ask you a question on Delphi?
Thread Solved |
•
•
Join Date: Feb 2009
Posts: 93
Reputation:
Solved Threads: 0
May I ask you a question on Delphi? The following is my question:
Write a program that asks for two numbers from the user. Add these numbers together and store them. Then output to the screen the equation with the correct answer. Eg
please enter a number
28
please enter another number
3
thank you
28 + 3 = 31
But I do in this way:
Could you tell me how can I show: 28 + 3 = 31 ??
Cheers,
Write a program that asks for two numbers from the user. Add these numbers together and store them. Then output to the screen the equation with the correct answer. Eg
please enter a number
28
please enter another number
3
thank you
28 + 3 = 31
But I do in this way:
Pascal and Delphi Syntax (Toggle Plain Text)
program sumof2numbers; {$APPTYPE CONSOLE} uses SysUtils; Var number1, number2, total: integer; begin writeln ('Please enter a number'); readln (number1); writeln ('Please enter another number'); readln (number2); total :=number1+number2; writeln ('The total of the two entered numbers is ',total,' ,'); sleep (50000)
Could you tell me how can I show: 28 + 3 = 31 ??
Cheers,
the answer is very simple...
delphi Syntax (Toggle Plain Text)
Program sumof2numbers; {$APPTYPE CONSOLE} Uses SysUtils; Var number1, number2, total: integer; ch1,ch2:Char; {add 2 vars as chararacter type} Begin ch1:='+'; ch2:='='; writeln ('Please enter a number'); readln (number1); writeln ('Please enter another number'); readln (number2); total :=number1+number2; writeln ('The total of the two entered numbers is '); WriteLn(number1,ch1,number2,ch2,total); ReadLn; End.
Be a good part of the community.Don't be ungrateful.
If you ask something on the forum and you got the right answer then mark as solved!
If my opinion helped to you a lot then sometimes give reputation point to me.
I'm just a pascal programmer from Hungary.
Farewell...
If you ask something on the forum and you got the right answer then mark as solved!
If my opinion helped to you a lot then sometimes give reputation point to me.
I'm just a pascal programmer from Hungary.
Farewell...
or more simple
delphi Syntax (Toggle Plain Text)
Program sumof2numbers; {$APPTYPE CONSOLE} Uses SysUtils; Var number1, number2, total: integer; Begin writeln ('Please enter a number'); readln (number1); writeln ('Please enter another number'); readln (number2); total :=number1+number2; writeln ('The total of the two entered numbers is '); WriteLn(number1,'+',number2,'=',total);{see this line} ReadLn; End.
Be a good part of the community.Don't be ungrateful.
If you ask something on the forum and you got the right answer then mark as solved!
If my opinion helped to you a lot then sometimes give reputation point to me.
I'm just a pascal programmer from Hungary.
Farewell...
If you ask something on the forum and you got the right answer then mark as solved!
If my opinion helped to you a lot then sometimes give reputation point to me.
I'm just a pascal programmer from Hungary.
Farewell...
In the pascal lang almost every commands ended with semicolon ;
except Begin or the end of the main program End.,it is ended with dot.
if you want to know a contetnt of a variable then you have to reference it by its name without apostrophe.
Look at this example:
Program commas_and_delimiters;
Var digit:Char;
Begin
digit:='#';
WriteLn(digit); {this line writes digit's contents,like #}
{if you want to write to the screen then do it by apostrophe}
WriteLn('Press enter to quit...');
{if you want to write to the screen and write the contents
of digit, detach them with comma}
WriteLn('The first character is ',digit);
{if you have another thought too,then detach with comma and
put the thoughts after that,of course between apostrophe}
WriteLn('The first character is ',digit,'.Guess it please');
{if you want to write to the screen four times
the contents of the reserved area by the compiler,called digit
,call its name detach them with comma}
WriteLn(digit,digit,digit,digit);
End.{end of main program}
I hope that you understood now
except Begin or the end of the main program End.,it is ended with dot.
if you want to know a contetnt of a variable then you have to reference it by its name without apostrophe.
Look at this example:
Program commas_and_delimiters;
Var digit:Char;
Begin
digit:='#';
WriteLn(digit); {this line writes digit's contents,like #}
{if you want to write to the screen then do it by apostrophe}
WriteLn('Press enter to quit...');
{if you want to write to the screen and write the contents
of digit, detach them with comma}
WriteLn('The first character is ',digit);
{if you have another thought too,then detach with comma and
put the thoughts after that,of course between apostrophe}
WriteLn('The first character is ',digit,'.Guess it please');
{if you want to write to the screen four times
the contents of the reserved area by the compiler,called digit
,call its name detach them with comma}
WriteLn(digit,digit,digit,digit);
End.{end of main program}
I hope that you understood now
Be a good part of the community.Don't be ungrateful.
If you ask something on the forum and you got the right answer then mark as solved!
If my opinion helped to you a lot then sometimes give reputation point to me.
I'm just a pascal programmer from Hungary.
Farewell...
If you ask something on the forum and you got the right answer then mark as solved!
If my opinion helped to you a lot then sometimes give reputation point to me.
I'm just a pascal programmer from Hungary.
Farewell...
•
•
Join Date: Feb 2009
Posts: 93
Reputation:
Solved Threads: 0
•
•
•
•
In the pascal lang almost every commands ended with semicolon ;
except Begin or the end of the main program End.,it is ended with dot.
if you want to know a contetnt of a variable then you have to reference it by its name without apostrophe.
Look at this example:
Program commas_and_delimiters;
Var digit:Char;
Begin
digit:='#';
WriteLn(digit); {this line writes digit's contents,like #}
{if you want to write to the screen then do it by apostrophe}
WriteLn('Press enter to quit...');
{if you want to write to the screen and write the contents
of digit, detach them with comma}
WriteLn('The first character is ',digit);
{if you have another thought too,then detach with comma and
put the thoughts after that,of course between apostrophe}
WriteLn('The first character is ',digit,'.Guess it please');
{if you want to write to the screen four times
the contents of the reserved area by the compiler,called digit
,call its name detach them with comma}
WriteLn(digit,digit,digit,digit);
End.{end of main program}
I hope that you understood now
Dear Sir,
Thank you for your detailed expression.
Cheers,
![]() |
Similar Threads
- Delphi vs C# (Pascal and Delphi)
- Binary constants??? (Pascal and Delphi)
- Delphi Remembering Help Question. (Pascal and Delphi)
- Delphi Unicode/RTF Question (Pascal and Delphi)
- Unresolved External Symbol Error (C++)
- Amount of virtual memory available? (Pascal and Delphi)
- Gettig delphi to wait for a button press before continuing (Pascal and Delphi)
- Delphi forum (Pascal and Delphi)
- Email crawler Software (C++)
Other Threads in the Pascal and Delphi Forum
- Previous Thread: using C# dlls in delphi
- Next Thread: Multithread+BDE+Oracle database Error
| Thread Tools | Search this Thread |





