Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


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 / vignesh1988i

no we cant define a function within a function.... but calling of function within a function is possible........

thank u

Is This Answer Correct ?    66 Yes 10 No

CAN WE DEFINE ANY FUNCTION WITHIN A FUNCTION...

Answer / prof.gagandeep jagdev

No, it is not possible to define any function within a
function. However we can call a function from within
another function.

Is This Answer Correct ?    30 Yes 4 No

CAN WE DEFINE ANY FUNCTION WITHIN A FUNCTION...

Answer / aparna

no....we cant define a function with in another
fn......Insteadwe can declare a function..
ex:
void main()
{
int fun(int); // this is declaration
fun(3); // this is fn. calling
}



int fun(int a) //this is fn.definition
{


}

Is This Answer Correct ?    22 Yes 2 No

CAN WE DEFINE ANY FUNCTION WITHIN A FUNCTION...

Answer / shailender

We can do nesting of functions. I tried in GCC.
check this keyword auto does the magic.

int main()

{

func1();

}



func1()

{

int i = 0;

auto func2()

{

i = 10;

printf("Heloo i am func 2\n");

}

printf("Heloo i am func 1\n");

}


However it seems to me that there is no use of doing this
if you want to call func2 you can't do it from out side func1.

Is This Answer Correct ?    12 Yes 2 No

CAN WE DEFINE ANY FUNCTION WITHIN A FUNCTION...

Answer / chandan patel

absolutely no......
u can't do this....u can only declared and call a function
inside a function....

i m appealing to those people who r saying 'yes' that please
don't misguide other....if u don't know correct stuff.

Is This Answer Correct ?    10 Yes 3 No

CAN WE DEFINE ANY FUNCTION WITHIN A FUNCTION...

Answer / blaaze

hey guys pls dont misguide......
the correct ans is "no" , we cant define a function within another.

Is This Answer Correct ?    8 Yes 2 No

CAN WE DEFINE ANY FUNCTION WITHIN A FUNCTION...

Answer / vinod kumari

No, we can not define a function within another function.
we can only declare and call any function in any other
function.

Is This Answer Correct ?    8 Yes 2 No

CAN WE DEFINE ANY FUNCTION WITHIN A FUNCTION...

Answer / nimish salve

yes it is possible to define a function inside function.but only in optimized compiler like GCC,DEV C and not in turbo c,visual c++.

try this code

#include<stdio.h>
void fun1(void)//function definition 1
{
printf("Inside fun1\n");
void fun2(void)//function definition for 2nd function
{
printf("Inside fun2\n");
}
fun2();//function call
}
int main()
{
printf("Inside Main\n");
fun1();//function call
return 0;
}

try in both GCC and TurboC and get your answer

Is This Answer Correct ?    3 Yes 0 No

CAN WE DEFINE ANY FUNCTION WITHIN A FUNCTION...

Answer / shiva

No.
in g++ you will be clearly notified that you can't define a
function inside another function
but gcc somehow allows following

#include <stdio.h>

int func2(int (*f)()){
(*f)();
return 0;
}
int main ()
{
int func1 ()
{
printf ("\n Inside func 1 ");
return 0;
}
printf("someting");
func1 (); //you can access this fuction inside
main(the function in which you declared func1) with the name
func1
func2(func1); // to access this function outside use
fucntion pointer as a argument
return 0;
}

o/p:
something
Inside func 1
Inside func 1

Is This Answer Correct ?    1 Yes 0 No

CAN WE DEFINE ANY FUNCTION WITHIN A FUNCTION...

Answer / shivang

No we cannot define any function within any function.Even
though i read it in book by yeshwant kanetkar,i also tested
it, my program generated an error while doing so.

Is This Answer Correct ?    2 Yes 1 No

Post New Answer

More C Interview Questions

Why void is used in c?

0 Answers  


write a program to display all prime numbers

0 Answers  


What is memmove?

1 Answers   Oracle,


What is the use of #include in c?

0 Answers  


char ch=10;printf("%d",ch);what is the output

14 Answers   Accenture,


What is a 'null pointer assignment' error?

0 Answers  


2. Counting in Lojban, an artificial language developed over the last fourty years, is easier than in most languages The numbers from zero to nine are: 0 no 1 pa 2 re 3 ci 4 vo 5 mk 6 xa 7 ze 8 bi 9 so Larger numbers are created by gluing the digit togather. For Examle 123 is pareci Write a program that reads in a lojban string(representing a no less than or equal to 1,000,000) and output it in numbers.

3 Answers   Nagarro,


if we take a number as a char then can we manipulate(add, subtract) on this number

2 Answers  


what is the output for the code : main() { int i,j; printf("%d %d ",scanf("%d%d",&i,&j)); }

20 Answers   Infosys,


write a C program, given number is double without using addt ion and multiplication operator?ex:n=6,ans=12,pls send me ans to goviseenu@gmail.com

6 Answers  


How does #define work?

0 Answers  


Write a C Program to display the following menu: Menu 1. Display 2. Copy 3. Append 4. Exit Accept the choice (1-4) from the user, and perform the following tasks: Choice 1: Accept a file name from the user and display the file on screen Choice 2: Accept two file names, and copy first file to the second Choice 3: Accept two file names, and append second file to the first file Choice 4: Terminate the program

1 Answers   Accenture, Concor, DMU, Satyam, Syntel, Tora,


Categories