0

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?

4
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by m610
Featured Replies
  • Hi [b]turbomen[/b]! I have an idea in [b]pascal[/b] :) [code=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:='*'; … Read More

1

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=-
}
Comments
He help me a lot.
0

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

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.