Go Back   Forums > Community Chatterbox > Tech Corner > Programming
Memberlist Forum Rules Search Today's Posts Mark Forums Read
Search Forums:
Click here to use Advanced Search

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Old 04-05-2005, 03:30 PM   #1
The Fifth Horseman
FUTURE SCIENCE BASTARD
 
The Fifth Horseman's Avatar


 
Join Date: Oct 2004
Location: Opole, Poland
Posts: 14,276
Default

I got an example task like those that might appear during the exams next week and I have certain trouble...

Quote:
program wykladniki;
uses crt;
var a:longint; n:longint; wynik:longint; x:longint; k:longint;

begin
clrscr;
writeln('Podaj podstawę potęgi:');
readln(a);
writeln('Podaj wykładnik:');
readln(n);
wynik:=1;
x:=a;
k:=n;
readkey;
repeat
begin
* if Odd(k) then
* begin
* wynik:= wynik * x;
* k:= k - 1;
* end
* else
* begin
* k:= k / 2 ;
* x:= x * x ;
* end;
writeln('' ,wynik);
end
until k>0;
end.
Odd(k) requires k to be of an integer type. On the other hand, k:= k / 2 requires the k to be of real type.
In theory I could try something with extra variables and stuff, but in this task I am limited to pre-defined variables with no space for this...

I ran outta ideas so far... got any?
__________________

"God. Can't you people see I'm trying to commit a crime against science and nature here?"
-- Reed Richards
The Fifth Horseman is offline                         Send a private message to The Fifth Horseman
Reply With Quote
 


Similar Threads
Thread Thread Starter Forum Replies Last Post
Log-in trouble MM_not_logged_in_sorta Old Suggestions 3 30-06-2009 10:37 AM
Trouble i need help please IshaMushaHaya General compatibility fixes 3 02-07-2008 11:16 AM
Trouble dynamite1 Troubleshooting 8 11-04-2006 07:39 AM
Need To Learn Turbo Pascal 7... Fast! The Fifth Horseman Programming 17 11-03-2005 02:02 PM
Trouble With Wc Darren Lauck Troubleshooting 3 03-03-2005 02:41 PM

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump
 


The current time is 05:30 AM (GMT)

 
Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.