Recent

Author Topic: These codes running but ı havent no result  (Read 6635 times)

cheejin

  • New member
  • *
  • Posts: 7
These codes running but ı havent no result
« on: March 06, 2018, 05:30:54 pm »
https://imgur.com/a/aJzzt

Did ı make any mistakes? that is running but I didnt get any result(I enter age of people) ...I guess ı will have a topic a lot of until the learn
« Last Edit: March 06, 2018, 05:32:25 pm by cheejin »

rvk

  • Hero Member
  • *****
  • Posts: 6110
Re: These codes running but ı havent no result
« Reply #1 on: March 06, 2018, 05:34:19 pm »
Try posting the code here instead of an image. Put the code between the cide-tags (you can use # when creating a post).

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: These codes running but ı havent no result
« Reply #2 on: March 06, 2018, 05:36:21 pm »
you have two "end." statements.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

cheejin

  • New member
  • *
  • Posts: 7
Re: These codes running but ı havent no result
« Reply #3 on: March 06, 2018, 05:38:28 pm »
you have two "end." statements.
But my teacher said that like ? Can you fix clearly ?

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: These codes running but ı havent no result
« Reply #4 on: March 06, 2018, 05:44:39 pm »
you have two "end." statements.
But my teacher said that like ? Can you fix clearly ?
sorry that makes no sense to me but here goes a complete explanation. Only one "end." statement is allowed, you have two. Everything after the first "end." statement is ignored by the compiler. If there is something unclear to you try posting in your language and see if some one else understands.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

cheejin

  • New member
  • *
  • Posts: 7
Re: These codes running but ı havent no result
« Reply #5 on: March 06, 2018, 05:52:33 pm »
Code: Pascal  [Select][+][-]
  1. program p6;
  2. label a;
  3. var ort,n,top:integer;
  4. say:byte;
  5. Begin
  6. top:=0;
  7. say:=0;
  8. a:writeln('enter age of one people');
  9. readln(n);
  10. top:=top+n;
  11. say:=say+1;
  12. If(say<3)then goto a;
  13. writeln('top/3');
  14. writeln('average=',top/3);
  15. Readln;
  16. End.

It is running like this...
Btw taazz dont be angry bro,just ı am here for learn. What you told me that was true,ı didnt ask in class.

Phemtik

  • New Member
  • *
  • Posts: 19
Re: These codes running but ı havent no result
« Reply #6 on: March 06, 2018, 06:20:13 pm »
The Example looked a bit antiquated.
No one use GoTo any more. It is not needed, because today we have a lot of possibility's to avoid GoTo. Like break, continue and exit for loop and functions.

I would write that example in this way.
Code: Pascal  [Select][+][-]
  1. program p6;
  2.  
  3. const
  4.     NumberPeople = 3;
  5.  
  6. var
  7.     n: PtrInt = 0;
  8.     top: Double = 0;
  9.     say: PtrUInt = 0;
  10.  
  11. Begin
  12.     while say < NumberPeople do
  13.     begin
  14.         writeln('enter age of one people');
  15.         readln(n);
  16.         top := top + n;
  17.         inc(say);
  18.     end;
  19.     writeln('top / 3');
  20.     writeln('average = ',top / NumberPeople);
  21.     Readln;
  22. End.
Intel i7-3610QM
Fedora 28

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: These codes running but ı havent no result
« Reply #7 on: March 06, 2018, 07:40:52 pm »
Btw taazz dont be angry bro,just ı am here for learn. What you told me that was true,ı didnt ask in class.
what makes you think I was angry?
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

jamie

  • Hero Member
  • *****
  • Posts: 6090
Re: These codes running but ı havent no result
« Reply #8 on: March 07, 2018, 03:21:19 am »
Hey, don't knock it, I've found some good use of GOTO where I need to repeat a case statement to
rerun a earlier part of the case.

 of course it thinks go wrong it could dead lock, you do need to make sure it'll never do that ;)

The only true wisdom is knowing you know nothing

RAW

  • Hero Member
  • *****
  • Posts: 868
Re: These codes running but ı havent no result
« Reply #9 on: March 07, 2018, 03:45:13 am »
BAD TEACHER !!!!

// nothing more to say...

EDIT: OK.. one more thing...
I like it like this:
Code: Pascal  [Select][+][-]
  1. PROGRAM AverageAge;
  2.  
  3.  USES
  4.   Crt, Keyboard, SysUtils;
  5.  
  6.  Function KeyInput: Char;
  7.    Var
  8.     Key: TKeyEvent;
  9.   Begin
  10.    InitKeyBoard;
  11.     Try
  12.      Key:= GetKeyEvent;
  13.      Key:= TranslateKeyEvent(Key);
  14.      Result:= GetKeyEventChar(Key);
  15.     Finally
  16.      DoneKeyboard;
  17.     End;
  18.   End;
  19.  
  20.  Function WaitForEscOrEnter: Char;
  21.   Begin
  22.    Repeat
  23.     Result:= KeyInput;
  24.    Until (Result = #27) Or (Result = #13);
  25.   End;
  26.  
  27.  Procedure CalcAverageAge;
  28.    Var
  29.     booQuit: Boolean;
  30.     strAge : String;
  31.  
  32.     iAge, iCount, iSum: Integer;
  33.   Begin
  34.    booQuit:= False;
  35.    iSum   := 0;
  36.    iCount := 1;
  37.  
  38.    While Not booQuit // Main Program Loop
  39.    Do
  40.     Begin
  41.      ClrScr;
  42.  
  43.      WriteLn('===============');
  44.      WriteLn('  AVERAGE AGE');
  45.      WriteLn('===============');
  46.      WriteLn;
  47.      WriteLn('Please Enter The Age Of Person ', iCount);
  48.  
  49.      ReadLn(strAge);
  50.       If TryStrToInt(strAge, iAge) // Real Numer ?
  51.       Then
  52.        Begin
  53.         Inc(iSum, iAge);
  54.  
  55.         WriteLn;
  56.         WriteLn;
  57.         WriteLn('The Average Age Of All Persons Is ', iSum/iCount:4:2);
  58.         WriteLn;
  59.         WriteLn('ESC   = Quit');
  60.         WriteLn('ENTER = Next');
  61.  
  62.         Inc(iCount);
  63.  
  64.         If WaitForEscOrEnter = #27 // ESC
  65.         Then Break;
  66.        End;
  67.     End;
  68.   End;
  69.  
  70.  
  71. BEGIN
  72.  CalcAverageAge;
  73. END.
« Last Edit: March 07, 2018, 07:54:42 pm by RAW »
Windows 7 Pro (x64 Sp1) & Windows XP Pro (x86 Sp3).

ccrause

  • Hero Member
  • *****
  • Posts: 845
Re: These codes running but ı havent no result
« Reply #10 on: March 07, 2018, 06:16:19 am »
BAD TEACHER !!!!
Let us hope the next lessons will be the same task but then solving it with all the different Pascal loop constructs:
  • while - see example by Phemtik
  • repeat until
  • for

cheejin

  • New member
  • *
  • Posts: 7
Re: These codes running but ı havent no result
« Reply #11 on: March 07, 2018, 07:17:40 am »
Fellas ı solved this problem,ı show this on my other reply(its work) .Thank you everyone..I know my teacher was wrong

Kays

  • Hero Member
  • *****
  • Posts: 569
  • Whasup!?
    • KaiBurghardt.de
Re: These codes running but ı havent no result
« Reply #12 on: March 07, 2018, 05:02:43 pm »
BAD TEACHER !!!!

There are scarce situations where break is tolerated. Three weeks ago I came up (or made up [if you prefer to say]) an example in the break” Wiki article.
Yours Sincerely
Kai Burghardt

RAW

  • Hero Member
  • *****
  • Posts: 868
Re: These codes running but ı havent no result
« Reply #13 on: March 07, 2018, 07:58:51 pm »
Quote
There are scarce situations where break is tolerated. Three weeks ago I came up (or made up [if you prefer to say]) an example in the “break” Wiki article.

I don't understand ??? What's the problem with "BREAK" ???

BREAK <> GOTO

Quote
what makes you think I was angry?
Your avatar !!!  :D
« Last Edit: March 07, 2018, 08:34:47 pm by RAW »
Windows 7 Pro (x64 Sp1) & Windows XP Pro (x86 Sp3).

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: These codes running but ı havent no result
« Reply #14 on: March 07, 2018, 10:13:43 pm »
Quote
what makes you think I was angry?
Your avatar !!!  :D
roflmo

that's not anger that's hunger
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

 

TinyPortal © 2005-2018