I gotta say that sucks, but considering its a free course.. You could have read about.com, cprogramming.com, cpluscplus.com, and etc. tutorials and have gotten how to do this. If you need that much explanation, and considering its a semester, I recommend getting 2 C++ books, it WILL be necessary in your situation. Accelerated C++ and C++ Primer Plus are my recommendations.
The factors of N:
The sum of its factors are :
Half of N is
N is DWARF
- Use cin >> to put N into a variable.
- Make an array arrayofFactors to hold the arrays, allocated at say 15 values of int.
- To calculate the factors you could use a for loop that runs while some variable is > 1, and < N / 2.
Code:
e.g. for(int i = 1; i <= N / 2 && i > 0; i++)
- Then inside the for loop you use the modulus operator % that checks if N % i is equal to 0.
Code:
e.g. if(N % i == 0) {
arrayofFactors[j] = i;
j++; }
- The j there is the number of factors found so far, and obviously arrayofFactors is the ones found.
- Simply use a for loop and print the array of factors.
- Simply use a for loop to add the array of factors together.
e.g. factorSum += arrayofFactors[i];
- To calculate half of N simply: variable / 2, and cout << that.
N is DWARF? just cout << the variable.
Some of that syntax might be incorrect , how about you try posting ANYTHING you can figure out for yourself, and dont just try the first part and if you cant do it give up, skip to the next part, and post everything and describe what you cannot figure out how to do.