CAN WE DEFINE ANY FUNCTION WITHIN A FUNCTION.

Answers were Sorted based on User's Feedback



CAN WE DEFINE ANY FUNCTION WITHIN A FUNCTION...

Answer / rg

no!!! we cant define a func. inside a func.

Why u some people misguide others!!

go thru practice..

Is This Answer Correct ?    0 Yes 0 No

CAN WE DEFINE ANY FUNCTION WITHIN A FUNCTION...

Answer / anil kumar nahak

Yes we define any function(without main()) with in a function.

Is This Answer Correct ?    3 Yes 4 No

CAN WE DEFINE ANY FUNCTION WITHIN A FUNCTION...

Answer / punam

Thank you all. This was helpful to me. So, to summarize all this should I say:
1. In C, we cannot define a function inside another function.
2. However, main() function is an exception as we can define another function inside a main() function. This can be called nesting of function inside main(). The inner function cannot be called from any outside function. It can be called only from main().
3. The only way to access the inner function from outside main() is by passing a function pointer of type inner function.

Is This Answer Correct ?    0 Yes 1 No

CAN WE DEFINE ANY FUNCTION WITHIN A FUNCTION...

Answer / vrushali

Hi friends , it possible.
Please chk this simple program:
#include <stdio.h>

int main ()
{
int func1 ()
{
printf ("\n Inside func 1 ");
}
func1 ();
}
O/P : Inside func 1

Is This Answer Correct ?    9 Yes 17 No

CAN WE DEFINE ANY FUNCTION WITHIN A FUNCTION...

Answer / kojo maxwell

yes a function can be defined in a function.
for example;
int main()
{

}
int main is a function and in the curly brackets we could
still have functions.

Is This Answer Correct ?    16 Yes 51 No

Post New Answer

More C Interview Questions

1) There is a singing competition for children going to be conducted at a local club. Parents have been asked to arrive at least an hour before and register their children’s names with the Program Manager. Whenever a participant registers, the Program Manager has to position the name of the person in a list in alphabet order. Write a program to help the Program Manager do this by placing the name in the right place each time the Program Manger enters a name. The Logic should be written in Data Structures?

0 Answers   KPIT,


How is null defined in c?

0 Answers  


How many types of functions are there in c?

0 Answers  


What are volatile variables in c?

0 Answers  


difference between native and cross compilers

0 Answers  


If errno contains a nonzero number, is there an error?

0 Answers  


Explain how does flowchart help in writing a program?

0 Answers  


How to write a program for swapping two strings without using 3rd variable and without using string functions.

7 Answers   iGate, Infotech,


What is a newline escape sequence?

0 Answers  


Explain how many levels deep can include files be nested?

0 Answers  


How can I read a directory in a C program?

2 Answers   Bright Outdoor, Wipro,


Code for calculating square root without using library function, of math.h

4 Answers   IBM,


Categories