Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

Trying to learn

+4 votes
asked May 19 by John Chung (330 points)
Thank you inadvance. I apologise if my question is stupid!

I am trying to use user defines functions and my test code actually works but I get warning erros which I do not understand:. The warning errors are as follws:

my_array.c: In function 'main':
my_array.c:24:5: warning: implicit declaration of function 'myarray' [-Wimplicit-function-declaration]
my_array.c: At top level:
my_array.c:50:1: warning: return type defaults to 'int' [-Wimplicit-int]
my_array.c: In function 'myarray':
my_array.c:50:1: warning: type of 'i' defaults to 'int' [-Wimplicit-int]

My code is:

#include <stdio.h>

#include <unistd.h> // For sleep function

// Function prototype (declaration)

void countDown(int initialValue);

void countUp(int baseValue);

int main() {

    int y = 11;

    int x = 0;

    int i=0;

    // char ponumarray[12] [12] = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};


    // Call the user-defined function



    // Call the second user-defined function



    // Call the third user-defind function


return 0;


// Function definition

void countDown(int initialValue)


    while (initialValue > 1) {

        sleep(1); // Wait for 1 second


        printf("%d  ", initialValue);



void countUp(int baseValue)


    while (baseValue < 10) {

        sleep(1); // Wait for 1 second


        printf("%d  ", baseValue);





printf("  \n\n");


char ponumarray[12] [10] = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};

printf ("String array elements are:\n\n");

printf("   \n");

//for (int i=0; i <13; i++)

while ( i < 12) {


    printf("%s\n", ponumarray[i]);






1 Answer

+1 vote
answered May 19 by John Chung (330 points)
Never mind - Thanks - figured it out.
commented May 20 by Peter Minarik (88,520 points)
edited May 21 by Peter Minarik
In case anyone runs into a problem like this, below is the solution for this and similar problems.

The problem is that the C/C++ compiler interprets the code from reading top-down. In the code above, the int myarray(int i); function is below the function that actually calls it, so when main() calls int myarray(int i), it hasn't parsed it yet, it doesn't know this function.

The simplest solution is to list all your functions at the top of the file (see // Function prototype (declaration) section).
commented May 20 by John Chung (330 points)
Excellent explanation. Thank you for taking the time to explain this.
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.