Exponents Using While/For Loops Programming Software Development by Delightfully …,num2): if (num2==0): return 1 else: return num1*exponents(num1,num2-1) Hey I was wondering how I can …generate a list of exponents using a for loop or a while loop so that… Re: Exponents Using While/For Loops Programming Software Development by TrustyTony …would use recursive generator with for: >>> def exponents(num1,num2): if (num2==0): yield 1 else: for r… in exponents(num1,num2-1): yield r yield num1 * r >>… Re: Exponents Using While/For Loops Programming Software Development by Delightfully Something like this perhaps? but this code does not work def exponents(num1,num2): if (num2==0): return (1) else: for r in exponents (num1**num2): return exponents Re: Exponents Using While/For Loops Programming Software Development by TrustyTony Ok you really are getting it hard. You are not needing to recurse, here is list comprehension version, you can alter it to append and for loop, if list comprehension is not yet covered for your course (this includes 1) def exponents(base, power): return [base ** power for power in range(power + 1)] exponents in c++ Programming Software Development by tyczj how do you write exponents in c++ i though it was "exp (#)" afterthe variable am i right? Exponents: whats double etc? Programming Software Development by grunge man Ok im learning how to do exponents in c++ and I get most of this, but I … Re: Exponents: whats double etc? Programming Software Development by WaltP [quote=grunge man;246061]Ok im learning how to do exponents in c++ and I get most of this, but I … adding exponents Programming Software Development by aaronmk2 …. First, I can't think of how to add the exponents in the overloaded method for *. Second when the two polynomials… don't know what to do here to add the exponents of the coefficients. This is also where I get zero… Coding some math with fractional exponents Programming Software Development by FriQenstein Hello all. I've a question regarding using fractions as exponents. Not quite sure how to start this in Java. For … Multiplying Exponents Programming Software Development by nickx522 I need help on "for" statement .Im doing exponents. I did a while statement already in which i checked … Re: Multiplying Exponents Programming Software Development by nickx522 ok in my code i need to do exponents...get first number as base then i need to get … postfix/prefix exponents Programming Computer Science by eagles39 How does postfix notation and prefix notation work for exponents because I know how postfix notation works on order of operations for plus, minus, division, multiplication. I would like to know how this works with the use of a stack in a pseudo-code format. Re: Exponents Using While/For Loops Programming Software Development by Delightfully Thanks for the help. I did not want to do the problem with the recursive but that was the only way i could do it, is there a way to do it with the ** cause I think I am doing it the hard way. I just did it that way cause i remember it from a while ago Re: exponents in c++ Programming Software Development by Dave Sinkula As a constant? [code]#include <iostream> int main() { double value = [COLOR=Blue]1.23456E+3[/COLOR]; std::cout << "value = " << value << '\n'; return 0; } /* my output value = 1234.56 */[/code] Re: exponents in c++ Programming Software Development by tyczj no not as a constant but never mind i figured it out. i have another question though, im getting an error and i have no clue what it means? "error c2447: missing function header (old-style formal list)" Re: exponents in c++ Programming Software Development by Narue >"error c2447: missing function header (old-style formal list)" And the line of code that goes with this error? Clearly you're trying to do something that looks something like a K&R style function definition, but C++ doesn't allow those. Re: exponents in c++ Programming Software Development by tyczj um not sure what K&R is; have not learned that yet but the line where the error is the "{" right after main to start writing the code Re: exponents in c++ Programming Software Development by Narue >um not sure what K&R is You aren't supposed to unless you have a perverse fascination with ancient dialects of C. >the line where the error is the "{" right after main That is soooooo incredibly [b]NOT[/b] helpful. Not even I can debug a program given one character (most of the time ;)). How about posting that line as … Re: Exponents: whats double etc? Programming Software Development by ~s.o.s~ Read this [URL]http://www.cplusplus.com/doc/language/tutorial/variables.html[/URL] and this [URL]http://goforit.unk.edu/cprogram/c_008.htm[/URL] Hope it helped, bye. Re: Exponents: whats double etc? Programming Software Development by Rashakil Fol Not only can you store larger numbers with doubles, the numbers are stored with more precision. Re: Exponents: whats double etc? Programming Software Development by dwks [quote]It simply means that the storage space (number of bytes) in a double is twice the storage space of a float.[/quote] Actually, the ANI standard just states that a double must be at least as large as a float (and a long double at least as large as a double). floats and doubles could be the same size, but if one of them is going to be bigger, … Re: Coding some math with fractional exponents Programming Software Development by javaAddict What code did you use? If I understood correctly, you need to know how to do this: a^b [CODE] double a = 8.0; double b = 1.0/3.0; double r = Math.pow(a,b); System.out.println(r); [/CODE] Check the API for the class: java.lang.Math for more. Re: Coding some math with fractional exponents Programming Software Development by FriQenstein [QUOTE=javaAddict;1206670]What code did you use? If I understood correctly, you need to know how to do this: a^b [CODE] double a = 8.0; double b = 1.0/3.0; double r = Math.pow(a,b); System.out.println(r); [/CODE] Check the API for the class: java.lang.Math for more.[/QUOTE] I tried something similar but I wasn't using a double... … Re: Multiplying Exponents Programming Software Development by WaltP What help do you need? When you ask for help, you need to describe a problem. Re: Multiplying Exponents Programming Software Development by WaltP Try reformatting your code correctly and you will probably notice a problem. [url=http://www.gidnetwork.com/b-38.html]See this[/url] Re: Multiplying Exponents Programming Software Development by nickx522 umm can you just help me find the problem..i am going to space everything out later...that doesnt effect the program. i need this as soon as possible. please Re: Multiplying Exponents Programming Software Development by nickx522 can someone help me with my problem? Re: Multiplying Exponents Programming Software Development by WaltP Reformat... That's one of the most important parts of programming. Rather than waiting 14 hours you could have done it in 5 minutes, Re: Multiplying Exponents Programming Software Development by nickx522 reformat what?? i tried reformatting but it wont work Re: Multiplying Exponents Programming Software Development by mike_2000_17 The point about reformatting is that you can spot mistakes in your code much more easily when the indentation is done properly. As a result, most programmers that have more than a few months of experience in coding are already fanatical about respecting format. It certainly won't magically fix any problems because the compiler ignores it, but it …