Monday, May 24, 2010

How can i create a c++ code?

1. example of conversion number to word ?


2. example of fibonacci


3. example of sum of powers


4. example of reverse

How can i create a c++ code?
What??
Reply:were we asleep during the lectures.....





as m sure you are well aware yto create the code all you need is an editor, and if you want to make sure its valid a compiler
Reply:Yeah all you need is an editor.... try dreamweaver!
Reply:Here is some code sequences that may help you for the Fibonacci. Please note that you need to be careful how many iterations that you run because it can take a large ammount of time to make the calculations.





#include %26lt;iostream%26gt;





using namespace std;


long fib_num ( long );











int main()


{








long num = 0;


long sequence = 0;





cout %26lt;%26lt; " Enter a positive number and I will compute the Fibonacci sequence for that number: ";


cin %26gt;%26gt; num;


if ( num %26lt; 0)


{ cout %26lt;%26lt; " Number must be greater than zero " %26lt;%26lt; endl;


return 1;


}


cout %26lt;%26lt; endl %26lt;%26lt; endl;





sequence = fib_num(num);





cout %26lt;%26lt; " The " %26lt;%26lt; num %26lt;%26lt; "th number of the Fibonacci sequence is " %26lt;%26lt; sequence %26lt;%26lt; endl;





return 0;


}





long fib_num ( long n)


{


if ( n == 0)


{


return 0;


}





else if ( n == 1 )


{


return 1;


}


else


return fib_num( n -1) + fib_num(n-2);


}
Reply:So, let me guess you are looking for answers on a homework assignment that is due in the near future. Do like every one else and do the research on these topics. This is not the best forum to explain these complicated problems.
Reply:If you're referring to 'a c++ code', you've got a bit more to learn before you start trying to actually program I think.


No comments:

Post a Comment