for loop question.

This is a homework question, but I need hints on how to complete it. We did not go over this in-class and I have searched the web and textbook for answers

The question goes, " Assume the int variables i and result, have been declared but not initialized. Write a for loop header for the following loop body:

result = result * i;

When the loop terminates, result should hold the product of the odd numbers between 10 and 20."

There is a lot of things my textbook wouldn't teach such as what is illegal and legal to do in functions/ loops of different types.

I understand a odd number cannot be divided by 2, obviously, but how could i implement said statement into the for statement?
 
for ( result = 1; result < 20, result > 10, i +=;)
Hi,

The for loop consists of 3 parts:

1 The starting value
2 The end condition
3 The increment

The variable i is what you need to use for these.

Good Luck !!
Topic archived. No new replies allowed.