Thread: Quick help for a college student :/

1. Quick help for a college student :/

I am having trouble with line 13 ( int numberOfDigits =....) im getting a "type double unexpected" message. I'm pretty sure its something small, but im new to c++. any assistance would help

Code:
```#include <iostream>
#include <cmath>
using namespace std;

int main(){
cout << "Enter an interger strictly between 0 and 1000: ";
int number;
cin >> number;

//Calculations

int numberOfDigits = double ceil(log10(number + 0.1));

int lastDigit = number % 10;
number = number / 10;

int secondLastDigit = number % 10;
number = number / 10;

int thirdLastDigit = number % 10;
number = number / 10;

int sumOfDigits = lastDigit + secondLastDigit + thirdLastDigit;

int averageOfDigits = (lastDigit + secondLastDigit + thirdLastDigit) / 3;

cout << "The sum of the digits is " << sumOfDigits << endl;
cout << "The average of the digits is " << averageOfDigits << endl;
cout << "The number of digits is " << numberOfDigits << endl;

return 0;
}```

2. The function signature
Code:
`double ceil( double num )`
just tells you that the function takes a double as its argument, and that the value that it returns is a double. You don't use the keyword "double" in your code when you call the function.

In your program, since you are assigning the return value to an int, you should explicitly convert the double to an int, either with a C-style cast as in:
Code:
`int numberOfDigits = (int)ceil(log10(number + 0.1));`
or use C++ static-cast as described here: Type Casting

3. The behavior of this program will not be correct if only a one or two digit number is given.