Re: [algogeeks] Nested Function C

2012-10-03 Thread kranthi kumar
In C, there is no difference between rules for declaring and defining function and variable. So we can define the functions inside another function, but their scope is limited to that function only, In this example abf() is local function to abc(), it can't be accessed outside environment. On

Re: [algogeeks] Nested Function C

2012-10-03 Thread srikanth reddy malipatel
@rahul In Standard C you cant define a function inside another function but you can declare a function inside another function. (so the function can be defined outside the function). Eg:- #includestdio.h void abc() { printf(bac); void abf(); abf(); } void abf() { printf(bas);

[algogeeks] Re: Nested Function C

2012-10-03 Thread apsalar
True, we can't define a function within another function in standard C. gcc has an extension that allows nested functions - http://gcc.gnu.org/onlinedocs/gcc/Nested-Functions.html On Tuesday, October 2, 2012 3:37:04 PM UTC-4, rahul sharma wrote: Guys i have read that we cant define function

Re: [algogeeks] finding element in array with minimum of comparing

2012-10-03 Thread Kalidhakani J
@umer : also ur code wont work if the searching element is at the middle of the array... On Tue, Oct 2, 2012 at 11:43 PM, atul anand atul.87fri...@gmail.com wrote: @umer : how no. of comparison are reduced to half by moving both sidesyou have 2 if condition inside, so you are making 2

Re: [algogeeks] finding element in array with minimum of comparing

2012-10-03 Thread Umer Farooq
@Dave Thanks for pointing that out. But I still can't get what if elem is on first element or it is not present in the array? How is your code going to handle that situation? @Atul, Well yes, In the given question, the number of iterations were 2n. Which I have reduced to n+n/2. On Tue, Oct

Re: [algogeeks] Nested Function C

2012-10-03 Thread Saurabh Kumar
It's compiler dependent. gcc comes from GNU project. ANSI C doesn't allow nested function definitions. On 3 October 2012 01:06, rahul sharma rahul23111...@gmail.com wrote: Guys i have read that we cant define function in another function in c Then why this followung program running fine on gcc

Re: [algogeeks] Facebook question!

2012-10-03 Thread Sudhir
A solution in java without arrays... class Combinations { static ArrayListString words = new ArrayListString(); static void getCombinations(ArrayListString words) { for(int j=0;jwords.length;word++) { //find the index of the word String word = words.get(j); //for each words, get the