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.

Can we have two function with same name with different parametres in a single c programe?justify with a programe

0 votes
asked Mar 23, 2023 by asish sarkar (350 points)
Can have two function with same name with different parametres  in a single c programe?justify the answer  with simple c programe

1 Answer

0 votes
answered Mar 23, 2023 by Peter Minarik (86,040 points)

No, C does not allow function overloading. C++ however does!

The following program cannot be compiled into a valid C program but can be compiled as a C++ program (the top right corner allows language selection).

#include <stdio.h>

void print(int i)
{
    printf("Integral number with value: %d\n", i);
}

void print(float f)
{
    printf("Floating point number with value: %f\n", f);
}

int main()
{
    print(666);
    print(3.14f);
    return 0;
}
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.
...