Functions: Scope & Flexibility Lesson 2 Grader not recognizing function declarations

Hi,
I’m having difficulties with the current lesson regarding functions spanning multiple files (see title) and my code is as follows:

#include <iostream>
#include <cmath>

// Add declarations here:
double average(double, double);
int tenth_power(int);
bool is_palindrome(std::string);

int main() {
  
  std::cout << is_palindrome("racecar") << "\n";
  std::cout << tenth_power(3) << "\n";
  std::cout << average(8.0, 19.0) << "\n";
  
}

The function definitions are also in the separate file provided, and it does compile properly…

g++ -c main.cpp my_functions.cpp
g++ main.o my_functions.o
--OUTPUT--
1
59049
13.5

The grader still asks for function declarations, which are there. Not sure if I’m doing something wrong here. Thanks in advance.

Could you please post a link to the exercise?

2 Likes

https://www.codecademy.com/courses/learn-c-plus-plus/lessons/cpp-functions-scope-flexiblity/exercises/cpp-functions-multifile-programs
Sorry about that…

It seems the SCT is expecting the parameter names in addition to the types in your parameter lists:

double average(double num1, double num2);
int tenth_power(int num);
bool is_palindrome(std::string text);

Hope this helps!

2 Likes