Expand|Select|Wrap|Line Numbers
- /*
- File Name: lab5.c
- Author: Nick Cantey
- Description: This program gathers the properties of numbers entered.
- */
- #include <stdio.h>
- #define DIVIDE 10
- void integerDivideBy10 (int, int*, int*);
- int sumOfDigits (int);
- int main ()
- {
- int number, quotient, remainder, sum;
- prinft("Please enter an integer: ");
- scanf("%d", &number);
- while (number != 0);
- {
- void integerDivideBy10(number, int* quotient, int* remainder);
- sum = sumOfDigits(number);
- printf("%d / 10 is %d with a remainder of %d\n", number, quotient,
- remainder);
- printf("Please enter an integer: ");
- scanf("%d", &number);
- }
- }
- /*
- Function Name: integerDivideBy10
- Parameters: number, int* quotient, int* remainder
- Description: function divides by 10 and returns the quotient and remainder
- */
- void integerDivideBy10 (int number, int* quotient, int* remainder)
- {
- while ( number !=0 )
- {
- int* quotient = number / 10;
- int* remainder = number % 10;
- }
- }
- /*
- Function Name: sumOfDigits
- Parameters: number
- Description: funtion returns the sum of all "number"'s digits
- */
- int sumOfDigits (int number)
- {
- int sum = 0, remainder;
- while (number != 0)
- {
- remainder = number % DIVIDE;
- number = number / DIVIDE;
- sum += remainder;
- }
- return (sum);
- }
lab5.c:27: parse error before `int'
lab5.c: In function `integerDivideBy10':
lab5.c:47: warning: initialization makes pointer from integer without a cast
lab5.c:48: warning: initialization makes pointer from integer without a cast
Some one please look this over, and if someone could also explain why I am getting the initialization errors.
The purpose of this program is to ask the user for an "integer" and then take that integer and divide by 10. Then also take the "integer" and and gather the sum of the digits within that number. i.e. 123 = 1+2+3 = 6 .