i tried running this on DarkBasic... didnt work... oh well, sorry i cant see your greatness banhammer!
I have been taking a c++ class for about 2 weeks. Ive done some silly little things using the standard cpp libraries but nothing really complexed.
Anyone whos taken a programming class will probably be familiar with this one. It is the Fibonacci program where you determine the nth number of the sequence. Mine has a slight twist however. The book wants me to use the sequence to determine how asexual things reproduce. In other words... basically you just multiply the initial value by the "final sum" which is actually just the place in the fibonacci sequence you determined.
BEHOLD MY CODE!
---------------------------
//Greatest program in the world.
//By: Alan Gardner
#include <iostream>
using namespace std;
int main()
{
int count;
// long long is HUGE! alast and blast are initialized.
long long alast, blast, sum, n;
int totamnt;
alast = 0;
blast = 1;
// Determines place in the sequence.
cout << "Enter time: ";
cin >> n;
cout << "\n";
// Determines inital amount (what to multiply final sum by).
cout << "Enter total amount: ";
cin >> totamnt;
cout << "\n";
switch (n)
{
// Catches 0 before it outputs a negative number.
case 0: cout << "0"; break;
// Catches 1 before it outputs 0.
case 1: cout << 1 * totamnt; break;
default:
// Determines place in the sequence.
for (count= 0; count < n-1; count++)
{
// "Rolls" numbers around to make the sequece work.
sum = alast + blast;
alast = blast;
blast = sum;
};
// Outputs the place in the sequence multiplied by the initial ammount.
cout << "\n" << sum * totamnt << " is the total amount."; break;
}
return 0;
}
-----
Since there are no extra libraries, you should be able to just compile right away.
i tried running this on DarkBasic... didnt work... oh well, sorry i cant see your greatness banhammer!
Nice work Capn 1 Time
PSN ID: splodger15
wow i need to take a course to help me learn c. (Even though i know nothing about it lol)
Congrats Cap'n 1 time
Come Visit Homebrew Heaven, Where you'll find the latest gaming news and downloads!
View My Coding Blog
The Return of The Lounge!
Mario Gold Rush
Current C++ Project: To be Announced soon on Homebrew Heaven
Currently Coding in: C++ for the PSP
lol, I only know html
I dont know about darkbasic, but im pretty sure it wont compile c++. I've never used it, but Dev c++ is supposed to make the compilation process easy for windows.
try this.
I highly recommend you take a beginners programming logic class before you take any computer languages. Without that class last semester I would be lost. Some people are able to pick the logic up right away... but I was not one of them.Originally Posted by Safari Al
the cplusplus.com website offers some good tutorials. Also keep in mind that C and C++ are similar, but are not the same.
if you really wanna be up to date id recommend you take c#
Thats silly. everything that I want and need to do can be done in C++ or C. The work place (generally) does not give a rats ass what language I use so long as I get the work done (though they usually demand a C derivative it seems). I know a few coders in these forums who would gladly burn you at the stake for saying such things.
Some people would actually argue that I'd be better off primarily using C rather than C++ while others would just say to code in whatever I am most comfortable in. New is not always better.
Wow! You actually coded something in C++ !!
Impossible! That's something out of this world ! You deserve a trophy!![]()
im taking ms dos then moving on to visual basic c++, who knows? i might make an app for the psp that uses the computer someday
BTW i only got as far as inputing co ordinates and making lines and playing music in MS DOS and also using the loop command lots
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks