Trouble writing programs

I am in a comp. science course and the college does not offer tutoring for assistance with C++. The course is also online so I am unable to ask the teacher to help with the code.

I am a complete beginner when it comes to coding. I don't know how to format the program. I also don't know where things are supposed to go.

I need to write a program that determines the number of potential team arrangements. I need to use the double type for this computation.

My code so far is :

#include <iostream>
#include <iomanip>

using namespace std;


int main()
{
const double n = 18; //Number of students in class.
const double r = 3; //Number of students per team.


}




If anyone can assist in walking me through this and teaching me, I would be grateful. This is due 2 Feb at 1159 cst I know that this is a short deadline but I have nowhere else to turn.

The formula I have to use to calculate this is:

n!/(r!(n-r)!)
Last edited on
formatting the program... for now, just indent one time for every compound statement or braces inside. You can post formatted code here using the editor's <> code support tags (look at the little window near where you make posts in the forum for it).

Ok, you have the formula.
you need a factorial function... how would you do that?
My personal preference is a lookup table of 64 bit integers
eg
unsigned long long fact[] = {1,1,2,6,24,120, ...}; //windows calc supports up to 18! and some beyond
and get them out with
fact[n](fact[r]* ... etc
and yes you can do fact[fact[n-r]] etc type statements if you need a compound one (might come into play later)
Last edited on
Topic archived. No new replies allowed.