KaijuX25's Profile
Reputation: -1
Dishonored
- Group:
- Members
- Active Posts:
- 26 (0.3 per day)
- Joined:
- 22-February 13
- Profile Views:
- 859
- Last Active:
Apr 09 2013 12:48 PM- Currently:
- Offline
Previous Fields
- Dream Kudos:
- 0
Posts I've Made
-
In Topic: Binary Tree program
Posted 5 Apr 2013
I forgot to mention that I need to insert all the numbers I showed above. -
In Topic: Sum of the Sum of Digits
Posted 29 Mar 2013
-
In Topic: Sum of the Sum of Digits
Posted 27 Mar 2013
jjl, on 27 March 2013 - 02:47 PM, said:It sounds like you just need to pass the result of DigitSum to another call of DigitSum
DigitSum(DigitSum(N));
Also, I don't know how big you guys are on math but you know a factorial of (for example)4 is the result of 4*3*2*1? I'm wondering what the math. term is for the result of calculating 4+3+2+1? Would you know what the name of that math term is? -
In Topic: Sum of the Sum of Digits
Posted 27 Mar 2013
jjl, on 27 March 2013 - 02:47 PM, said:It sounds like you just need to pass the result of DigitSum to another call of DigitSum
DigitSum(DigitSum(N));
I tried what you give me on 12345 and got 33. The MegaSum function is supposed to be recursive(in case that fact helps). If you think something's missing, here's my entire program. Everything except the MegaSum function works.
// Author: Connor Wells // Date: 3/26/2013 // Theme: Recursion Stuff #include <iostream> #include <cstdio> using namespace std; int CountDigits(int NB); int FirstDigit(int num); int DigitSum(int numb); int ReverseOrder(int NM); int MegaSum(int N); int Multiply(int x, int y); int PowerFunc(int C, int pow); int ArraySum(int A[], int SIZE); int main() { int number; int number2; int number3; int number4; int number5; int SZ = 5; int B[] = {10, 20, 30, 40, 50}; int CT; int FT; int SU; int REV; int MS; int PO; int MU; int AS; cout << "Enter a positive multi-digit number: "; cin >> number; cout << endl; cout << "Enter a number to be multiplied: "; cin >> number4; cout << endl; cout << "Now enter another number to be multiplied: "; cin >> number5; cout << endl; cout << "Enter a number to be raised power-wise: "; cin >> number2; cout << endl; cout << "Enter a number to act as the last number's exponent: "; cin >> number3; cout << endl; cout << "The content of content of said array is : "; for(int i = 0; i < SZ; i++) { cout << B[i] << " "; } cout << endl << endl; CT = CountDigits(number); FT = FirstDigit(number); SU = DigitSum(number); REV = ReverseOrder(number); MS = MegaSum(number); PO = PowerFunc(number2, number3); MU = Multiply(number4, number5); AS = ArraySum(B, SZ); cout << "The number of digits of " << number << " is " << CT << "." << endl << endl; cout << "The first digit of " << number << " is " << FT << "." << endl << endl; cout << "The sum of all the digits of " << number << " is " << SU << "." << endl << endl; cout << "The number " << number << " in reverse order is " << REV << "." << endl << endl; cout << "The mega-sum of all the digits of " << number << " is " << MS << "." << endl << endl; cout << number2 << " raised to the " << number3 << " power is " << PO << "." << endl << endl; cout << number4 << " times " << number5 << " equals " << MU << "." << endl << endl; cout << "The sum of all your array's content is " << AS << "." << endl << endl; return 0; } int CountDigits(int NB) { static int count = 0; if (NB > 0) { count++; CountDigits(NB / 10); } else { return 0; } return count; } int FirstDigit(int num) { static int first; if (num > 0) { first = num % 10; FirstDigit(num / 10); } else { return 0; } return first; } int DigitSum(int numb) { static int sum = 0; static int R; if (numb > 0) { R = numb % 10; sum = sum + R; DigitSum(numb / 10); } else { return 0; } return sum; } int ReverseOrder(int NM) { static int rev; static int SM; if (NM > 0) { rev = NM % 10; SM = SM * 10 + rev; ReverseOrder(NM / 10); } else { return 0; } return SM; } int MegaSum(int N) { if (N > 0) { return DigitSum(DigitSum(N)); } else { return 0; } } int PowerFunc(int C, int pow) { int result; if(pow <= 1) { result = C; } else { result = C * PowerFunc(C, pow - 1); } return result; } int Multiply(int x, int y) { if (y > 0) { return x + Multiply(x, y - 1); } else { return 0; } } int ArraySum(int A[], int SIZE) { if (SIZE <= 0) { return 0; } else { return A[SIZE - 1] + ArraySum(A, SIZE - 1); } } -
In Topic: Inventory report with linked lists
Posted 24 Mar 2013
jimblumberg, on 24 March 2013 - 01:45 PM, said:You won't dereference a null pointer until you read your file. I suggest you work on that first. Post your current code, I doubt you're even getting any information from the file yet.
Jim
No offense, but isn't the infinite loop causing the output to not be displayed?
My Information
- Member Title:
- New D.I.C Head
- Age:
- Age Unknown
- Birthday:
- Birthday Unknown
- Gender:
Contact Information
- E-mail:
- Click here to e-mail me
Friends
KaijuX25 hasn't added any friends yet.
|
|


Find Topics
Find Posts
View Reputation Given
|
Comments
KaijuX25 has no profile comments yet. Why not say hello?