Hey I am very new to C programming and I need help.
I am trying to make a program using the Do While loop only once to multiply all the even numbers from 1-10. Result being :3840
I have been trying for a long time now and can't figure out how to keep the last integer that was used in the prior loop to multiply against the next one if that makes sense. If that doesn't, here is what I am trying to do:
2X4X6X8X10 = 3840
I keep trying to increment the variable num by tempNum(2) each loop but I cant figure out how to keep that # for the next loop so that I can multiply them in order. Can you help?
Code:
#include <stdio.h>
void main(void)
{
int num, tempNum;
tempNum = 2;
do
{
num = num + tempNum;
num = num * num;
printf("Num = %d\n", num");
}while(num<=10);
}