Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Mathematical expression translator
#7
Hi Ralph,

Sure I will try to explain you what POW means:

Like in qbasic there is in C a mathematical function to compute the power exponent.
In qbasic we use ^ but in C it is called POW.

I will give some more example in both C and bqasic so you can see the differences.

Example in C
  printf ("7 ^ 3 = %lf\n", pow (7,3));
  printf ("4.73 ^ 12 = %lf\n", pow (4.73,12));
  printf ("32.01 ^ 1.54 = %lf\n", pow (32.01,1.54));

Example in qbasic
  print "7 ^ 3 = ", 7 ^ 3
  print "4.73 ^ 3 = ", 4.73 ^ 12
  print "32.01 ^ 1.54 = ", 32.01 ^ 1.54

Both should output something like this:
7 ^ 3 = 343.000000
4.73 ^ 12 = 125410439.217423
32.01 ^ 1.54 = 208.036691

Please forget the C syntax you see in the example.
A correct translation (according to this challenge) should translate print 3 ^ 7 to print pow(3,7).

Now this looks easy but things start to get more complicated when translating
print (10 ^ 2) - 5 + (21 * (3 - 4 ^ 6) * 2 + 10 - 5) ^ 2 + 3 - (3 + 7) + 99
To
print pow(10,2))-5+pow((21*(3-pow(4,6))*2+10-5),2)+3-(3+7)+99)

I hope that helped a little.

Kind regards,
Frontrunner
Reply


Messages In This Thread
Re: Mathematical expression translator - by Ralph - 04-23-2008, 05:40 AM
Re: Mathematical expression translator - by Frontrunner - 04-23-2008, 11:54 AM
Re: Mathematical expression translator - by Ralph - 04-23-2008, 11:09 PM
Re: Mathematical expression translator - by Ralph - 04-24-2008, 02:56 AM
Re: Mathematical expression translator - by Ralph - 04-24-2008, 07:51 AM
Re: Mathematical expression translator - by Ralph - 04-25-2008, 07:40 PM
Re: Mathematical expression translator - by Ralph - 04-26-2008, 12:40 AM
Re: Mathematical expression translator - by Ralph - 04-26-2008, 04:33 AM
Re: Mathematical expression translator - by Ralph - 04-29-2008, 08:30 AM
Re: Mathematical expression translator - by LPG - 04-29-2008, 10:57 AM
Re: Mathematical expression translator - by LPG - 04-30-2008, 09:06 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)