30 lines
814 B
C
30 lines
814 B
C
#include "General.h"
|
|
|
|
//---------------------------------------------------------------------------------------
|
|
// SumDigits
|
|
// ---------
|
|
//
|
|
// General : Count the amount of digits in a number.
|
|
//
|
|
// Parameters :
|
|
// num - a number (int)
|
|
//
|
|
// Return value : The count of digit in the number (unsigned short).
|
|
//
|
|
//---------------------------------------------------------------------------------------
|
|
// Programmer : Cohen Idan
|
|
// Student No : 211675038
|
|
// Date : 30.12.2019
|
|
//---------------------------------------------------------------------------------------
|
|
unsigned short SumDigits(int num)
|
|
{
|
|
if (num < TEN)
|
|
return (num);
|
|
else
|
|
return (SumDigits(num / TEN) + (num % TEN));
|
|
}
|
|
|
|
void main(void)
|
|
{
|
|
|
|
} |