Treasure of Knowledge

Skip to content

Send email to tutor@visharadsoftware.com if you want online tuition

a little problem (pascal)

a little problem (pascal)

Postby Aggyness_90 on Sat Dec 12, 2009 4:57 pm

Hello,....I've writen a program & it works v.well ....except sth (I'm ganna tell you,first read my program):

{Author: Farnoosh Hejazi
Description: read two numbers like m & n & do:
i)write the Phibonachy numbers that are between these two numbers
ii)write the first k Phibonachy numbers that are between the two numbers
iii)to seprate the even & odd phibonachy numbers that are between two numbers & write them in seprated lines
}
Program Phybonachy;
Uses wincrt;
Var
f1,f2,f3,f4,f5,f6,m,n,k,i,j,count:integer;
answer:char;
Begin{Main}
answer:='y';
While answer='y' do
Begin
writeln('Please,enter two numbers(n<m): *enter after you write each number*');
readln(n);
readln(m);
writeln('Now which item do you wanna choose?');
writeln('1)write the Phibonachy numbers that are between these two numbers');
writeln('2)write the first k Phibonachy numbers that are between the two numbers');
writeln('3)to seprate the even & odd phibonachy numbers & write them in seprated lines');
writeln('4)Exit');
readln(i);
f1:=0;
f2:=1;
f3:=f1+f2;
count:=0;
j:=1;
CLRSCR;
if i=1 then
Begin
While f3<n do
Begin
f1:=f2;
f2:=f3;
f3:=f2+f1;
End;{End of while}
While f3<=m do
Begin
write(f3:3);
f1:=f2;
f2:=f3;
f3:=f1+f2;
End;{End of while}
writeln;
writeln('Do you wanna continue?(y/n)');
readln(answer);
End
else if i=2 then
Begin
While f3<n do
Begin
f1:=f2;
f2:=f3;
f3:=f2+f1;
End;{End of while}
While f3<=m do
Begin
count:=count+1;
f1:=f2;
f2:=f3;
f3:=f1+f2;
End;{End of while}
writeln('There are ',count,' phibonachy numbers between your two numbers');
write('How many phibonachy numbers (between these two numbers)do you wanna be writen?');
readln(k);
if k<=count then
Begin
f1:=0;
f2:=1;
f3:=f2+f1;
While f3<n do
Begin
f1:=f2;
f2:=f3;
f3:=f2+f1;
End;{End of while}
for j:=1 to k do
Begin
write(f3:3);
f1:=f2;
f2:=f3;
f3:=f1+f2;
End;{End of for}
End
else if k>count then
writeln('Sorry,there are only ',count,' phybonachy numbers,not ',k,' phybonachy numbers!');
writeln;
writeln('Do you wanna continue?(y/n)');
readln(answer);
End
else if i=3 then
Begin
While f3<n do
{Begin}
Begin
f1:=f2;
f2:=f3;
f3:=f2+f1;
End;{End of while}
f6:=f1;
f5:=f2;
f4:=f3;
While f3<=m do
Begin
if f3 mod 2 =0 then
Begin
write(f3:2);
f1:=f2;
f2:=f3;
f3:=f1+f2;
End;
End;{End of while}
writeln;
f3:=f4;
f1:=f6;
f2:=f5;
While f3<=m do
Begin
if f3 mod 2 <> 0 then
Begin
write(f3:2);
f1:=f2;
f2:=f3;
f3:=f2+f1;
End;
End;{End of while}
{End;}
writeln;
writeln('Do you wanna continue?(y/n)');
readln(answer);
End
else if i=4 then
Begin
writeln(' ____________________________________');
writeln(' | |');
writeln(' | ********** ** ** ******* |');
writeln(' | ********** *** ** ****** * |');
writeln(' | ** **** ** ** * * |');
writeln(' | ********** ** ** ** ** * * |');
writeln(' | ********** ** ** ** ** * * |');
writeln(' | ** ** ** ** ** * * |');
writeln(' | ********** ** **** ****** * |');
writeln(' | ********** ** *** ****** |');
writeln(' |___________________________________|');
End;
End;{End of main-while}
CLRSCR;
writeln(' _________________________________');
writeln(' | |');
writeln(' | ********** ** ** ******* |');
writeln(' | ********** *** ** ****** * |');
writeln(' | ** **** ** ** * * |');
writeln(' | ********** ** ** ** ** * * |');
writeln(' | ********** ** ** ** ** * * |');
writeln(' | ** ** ** ** ** * * |');
writeln(' | ********** ** **** ****** * |');
writeln(' | ********** ** *** ****** |');
writeln(' |____________________________ ___|');
End.{End of program}

my problem is when I wanna choose item 3 ....the program won't responding!!!& I try in diferent ways!!what should i do??
(***i've copy the program text from my compiler.....in the end of my program i've drawn END with some stars ....& after i've pasted it here I couldn't fix it ,I was busy,sorry***)so if you see strang things know that it's the disign of end with some stars!!!!
Aggyness_90
 
Posts: 8
Joined: Fri Sep 19, 2008 12:50 pm

Return to Others

Who is online

Users browsing this forum: No registered users and 1 guest

cron