PROGRAM DOESNT GIVE ANYTHIN AS AN EXIT - Programmers Heaven

Howdy, Stranger!

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

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

PROGRAM DOESNT GIVE ANYTHIN AS AN EXIT

ExcaliburXExcaliburX Posts: 5Member
I POST MY PROGRAM... JUST TELL ME WHERE I AM WRONG...

program ask15(input,output);
var
i,j,k,l,count2,m:integer;
s:string[100];
a:string[20];
begin
while not eof do
begin
j:=0;
While j<=61 do
begin
i:=1;
repeat
read(a[i]);
until a[i]<>' ';
while (a[i]<>' ') and (i<20) do
begin
i:=i+1;
read(a[i]);
end;
if 60-j>=i+1 then
begin
j:=j+1;
s[j]:=' ';
for k:=1 to i-1 do
begin
j:=j+1;
s[j]:=a[k];
end;
if a[i]<>' ' then
begin
j:=j+1;
s[j]:=a[i];
end;
end
else
begin
count2:=60-j;
While count2>0 do
begin
l:=60;
while (l>=1) do
begin
if s[l]=' ' then
begin
insert(' ',s,l);
count2:=count2-1;
end;
l:=l-1;
end;
end;
end;
end;
for m:=1 to 60 do write(s[m]);
writeln;
end;
end.

Comments

  • ActorActor Posts: 438Member
    : I POST MY PROGRAM... JUST TELL ME WHERE I AM WRONG...
    :
    Please be more specific as to what the problem is.

  • ExcaliburXExcaliburX Posts: 5Member
    It keeps reading and reading and reading, without writing anything on the screen.
  • ExcaliburXExcaliburX Posts: 5Member
    It keeps reading and reading and reading, without writing anything on the screen.
  • ExcaliburXExcaliburX Posts: 5Member
    I WILL POST YOU A NEW PROGRAM OF MINE MADE TO DO THE SAME WORK. FINALLY IT DOESNT WRITE ANYTHING ON THE SCREEN TOO AND IT TERMINATES WRITIN BAD FILE DESCRIPTOR

    HERE IS THE PROGRAM... PLEASE HELP...

    program ask15(input,output);
    var
    i,j,l,count,k:integer;
    s:array[1..61] of char;
    a:array[1..21] of char;
    begin
    while not eof do
    begin
    j:=1;
    while j<=61 do
    begin
    repeat
    read(a[1]);
    until a[1]<>' ';
    i:=1;
    while (i<20) and (a[i]<>' ') do
    begin
    i:=i+1;
    read(a[i]);
    end;
    if i-1<=60-j+1 then
    begin
    for k:=1 to i-1 do
    begin
    s[j]:=a[k];
    j:=j+1;
    end;
    if i-1<60-j+1 then
    begin
    s[j]:=' ';
    j:=j+1;
    end;
    end
    else
    begin
    count:=60-j+1;
    k:=j-2;
    while count>0 do
    begin
    if s[k]=' ' then
    begin
    for l:=60 downto k+1 do
    begin
    s[l]:=s[l-1];
    count:=count-1;
    end;
    k:=k-1;
    end;
    end;
    j:=1;
    end;
    end;
    for l:=1 to 60 do write(s[i]);
    writeln;
    for l:=1 to i do
    begin
    s[l]:=a[l];
    j:=j+1;
    end;
    s[j]:=' ';
    end;
    end.

  • ActorActor Posts: 438Member
    Complex!

    I've worked with it for a while and all I can say is that I ams certain that you are stuck in a loop. I strongly suspect it is :
    [code]
    while j<=61 do
    [/code]
    Looking at the code suspect that the condition [b]j <= 61[/b] will ever fail.

    But it may be :
    [code]
    repeat
    read(a[1]);
    until a[1]<>' ';
    [/code]
    I think it would help if I knew what the program is supposed to do.

  • LegyPlegyLegyPlegy Posts: 5Member
    I may have no idea what is going on, but to me there is no write or writeln functions...
  • LegyPlegyLegyPlegy Posts: 5Member
    I may have no idea what is going on, but to me there is no write or writeln functions...
Sign In or Register to comment.