0 votes
in C Plus Plus by

What happens if the following program is executed in C and C++?

#include <stdio.h> 
void func(void)
{
	printf("Hello");
}
void main() 
{ 
	func();
	func(2);
}

a) Outputs Hello twice in both C and C++
b) Error in C and successful execution in C++
c) Error in C++ and successful execution in C
d) Error in both C and C++

1 Answer

0 votes
by

Answer: d
Explanation: As the func(void) needs no argument during its call, hence when we are calling func(2) with 2 as passed as a parameter then this statement gives the error in both C++ and C compiler.

Related questions

+1 vote
asked Oct 19, 2022 in C Plus Plus by AdilsonLima
0 votes
asked Dec 21, 2023 in C Plus Plus by GeorgeBell
...