HFX Forum

Programming => C/C++ => Topic started by: omahne on April 17, 2004, 03:46:12 PM

Poll
Question: need help with assignment
Option 1: imple votes: 0
Title: help with homework
Post by: omahne on April 17, 2004, 03:46:12 PM
ok, i need help.  i have to submit a homework assignment, beginner, and i am clueless.  i need to write a program that uses for structure to evaluate the factorials of the integars from 1 to 5.  please help.  failing!!!
Title: Re:help with homework
Post by: Metgod on April 21, 2004, 04:38:19 PM
Define 'for structure' ?

Do you mean 'for loop' ?

There is a difference, and I can't see a structure being used in this. I would suggset that you read up on both topics; C (or C++ if you use that instead) and factorials...

a for loop usually has the format of ..

for (initialization of variables; check; increment/next evaluation) {

code

}

The following example will print out a number, 0 through 5, on a seperate line each ...

int i;

for (i = 0; i < 6; i++)
{
printf("I is now %d", i);
}

You could use a very similar for loop if you're on about a number 1 - 5.. just modify it to your liking.

That's about all I have energy to explain though ...

BTW: You need to read _and_ experiment. If you rely on others, you won't get anywhere ....

Met