954,529 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Please help me again?

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?

turbomen
Junior Poster
113 posts since Feb 2009
Reputation Points: 10
Solved Threads: 0
 

Show what you have so far.

pritaeas
Posting Expert
Moderator
5,480 posts since Jul 2006
Reputation Points: 653
Solved Threads: 874
 

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=-
}
FlamingClaw
Posting Pro
559 posts since Feb 2009
Reputation Points: 132
Solved Threads: 138
 

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));

m610
Light Poster
41 posts since Oct 2008
Reputation Points: 10
Solved Threads: 1
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You