Skip to content
Related Articles

Related Articles

Save Article
Improve Article
Save Article
Like Article

A C/C++ Function Call Puzzle

  • Difficulty Level : Easy
  • Last Updated : 06 Jul, 2021

Consider the following program. Predict the output of it when compiled with C and C++ compilers.

Take a step-up from those "Hello World" programs. Learn to implement data structures like Heap, Stacks, Linked List and many more! Check out our Data Structures in C course to start learning today.

C




void func()
{
    /* definition */
}
 
int main()
{
    func();
    func(2);
}

The above program compiles fine in C, but doesn’t compile in C++.

In C++, func() is equivalent to func(void) 
In C, func() is equivalent to func(…)

Refer this for details and this for more programs that compile in C, but not in C++.

This article is compiled by Rahul Mittalal. If you like GeeksforGeeks and would like to contribute, you can also write an article and mail your article to review-team@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
 

My Personal Notes arrow_drop_up
Recommended Articles
Page :