Jump to content

Featured Replies

Posted

#include <iostream>
#include <string>
using namespace std;
int start;
int length;
unsigned long int value1;
unsigned long int value2;

int output_func()
{
value1=0;
value2=start;

cout << "\n";
cout << "\n";
cout << "\n";
cout << "Fibonacci series. Starting from [" << start << "] and lasting [" << length << "] integers :";
cout << "\n";
cout << "\n";
cout << "\n";
while (length >0)
{
value1=value1+value2;
value2=value1-value2;

            
cout << value1;
cout << ", ";
length =length-1;
}


cout << "\n";
cout << "\n";
cout << "\n";
cout << "Coded by Timmy! Learning C++!!!!!";
while (1) {}
return 0;

}

int input_func()
{
   cout << "This generator will work up to ten digits";
cout << "\n";
   cout << "\n";
   cout << "enter the starting number for the sequence: ";
   cin >> start;
   cout << "\n";
   cout << "\n";
   cout << "Thanks, now enter the length of the sequence: ";
   cin >> length;

   output_func();
   
}




int main()
{
   input_func();
}

 

 

:D what do you think!

Not bad, few things:

 

You can combine cout statements, e.g. cout << "\n\n\n";

 

Don't use "while (1) {}" to "pause" your app, that makes your app use 100% cpu time. Try getch(); or system("pause"); instead. (getch() is preferred, as it works on windows, linux, bsd, etc.) I forget what header files system() and getch() are defined in though... haven't done c++ in ages

 

And add a "return 0;" to the bottom of your main() function

Not bad, few things:

 

You can combine cout statements, e.g. cout << "\n\n\n";

 

Don't use "while (1) {}" to "pause" your app, that makes your app use 100% cpu time. Try getch(); or system("pause"); instead. (getch() is preferred, as it works on windows, linux, bsd, etc.) I forget what header files system() and getch() are defined in though... haven't done c++ in ages

 

And add a "return 0;" to the bottom of your main() function

getch(); is in conio.

Not bad, few things:

 

You can combine cout statements, e.g. cout << "\n\n\n";

 

Don't use "while (1) {}" to "pause" your app, that makes your app use 100% cpu time. Try getch(); or system("pause"); instead. (getch() is preferred, as it works on windows, linux, bsd, etc.) I forget what header files system() and getch() are defined in though... haven't done c++ in ages

 

And add a "return 0;" to the bottom of your main() function

 

Yeah, a while (1) loop is a horrible way to pause.

 

 

It's decent for a first app. You might want to work harder on organization.. It was hard to get through and comprehend because of the sloppy way it was coded.

What are you using to learn, online tutorials or a book, or something else? Also if its a book you torrented provide links :gaykeke:

Thanks for comments and advice. I will work harder to organise my code better and stop doing the while loop pause.

 

I got the tutorials off this website.

 

http://www.cplusplus.com/doc/tutorial/functions.html

Oh I forgot to mention, if you just want to have it pause for a few seconds, do:

 

Sleep(number_of_millseconds_here);

 

So Sleep(5000); = 5 second pause

if you want it to pause add this code.

 

system("PAUSE");

 

 

thx. :)

Ok I bookmarked that page, Im going to try my hand at this later. It wouldnt hurt to actually learn something from all the time I spend on the computer.

learn how to use bools properly in the future is all i ask :)

 

bool hai = false;

 

if (thishappens){

hai=!hai; //make a bool whatever its not if its true it == false now if false

//it == true now fun.

if(hai){ cout << "TRUE LOOLL"; }else{ cout << "wtf did you brake asshole"; }

}

/* (hai) is easier then saying (hai==true) */

/* (!hai) is easier then saying (hai==false) */

 

wee fun

 

your on the right track but i must admit all those newlines look ugly eww cout<<"\n\n\n\n\n\n\n"; ftw.

 

there goes my boolean tutorial

Not bad, few things:

 

You can combine cout statements, e.g. cout << "\n\n\n";

 

Don't use "while (1) {}" to "pause" your app, that makes your app use 100% cpu time. Try getch(); or system("pause"); instead. (getch() is preferred, as it works on windows, linux, bsd, etc.) I forget what header files system() and getch() are defined in though... haven't done c++ in ages

 

And add a "return 0;" to the bottom of your main() function

 

getch() i think is conio.h and system() is prolly windows or stdlib.h

Guest
This topic is now closed to further replies.