To design a program that works out the powers of numbers. For example
3^5 = 3*3*3*3*3 = 243
2^3 = 2*2*2 = 8
Please help me again?
Show what you have so far.
Hi turbomen!
I have an idea in pascal :)
{
To design a program that works out the powers of numbers. For example
3^5 = 3*3*3*3*3 = 243
2^3 = 2*2*2 = 8
}
Program Program01;
Uses Crt;
Var i:Byte;
a,b,c:LongInt;
word01:String[1];{it can be char too}
Begin {Main}
word01:='*';
{first number}
Readln(a);
ClrScr;
Write(a,'^');
{how many times}
Readln(b);
ClrScr;
{write the reults}
Write(a,'^',b,' = ');
c:=a;
For i:=1 To b Do
Begin
Write(c);
If (i=b) Then
Begin
Write(' = ',a);
Break;
End
Else Write(word01);
a:=a*c;
End;
ReadKey;
End.{end main}
{
-= Note By FlamingClaw =-
Created and tested in Dev Pascal!Working!
-= Created By FlamingClaw =-
-=2009.03.25=-
}
Delphi has a function called Power that does this.
Are you interested in only working with integers?
You could always do something like
for i:=0 to n do X:=X*X;
Write(IntToStr(X));
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.