Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

chris200x9

macrumors 6502a
Original poster
Jun 3, 2006
906
0
hey I have seemed to forgoten how to print functions in c++. Can someone help me? what do I need in main?
 

chris200x9

macrumors 6502a
Original poster
Jun 3, 2006
906
0
yea I know but ok heres my code NOW


Code:
#include <iostream>

using namespace std;
int Factorial( const int num )
{
	int t = 1;
	int total = 1;
	while( t <= num ) {
		total = total * t;
		t++;
	} // end while
cout << total;
	return total;
}

int main () {
int number;
int total;
cin >> number;

Factorial (number);



    return 0;
}


I get it to print the factorial but my teacher said never to put cout in the function to avoid mistake I'm just having a hard time remembering exactly what to cout so i can have the cout in the main and still ooutput the correct results.


ps. sorry for such a noob-ish question. and thanx very much.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.