1.Can you have both const and volatile qualifiers for single declaration in C? If so ,can you give me an example? If no, why not?

Ans: Yes we can have because if you want the value not to be changed by program and driver will change the value you can use this technique. Actually volatile qualifier is just to tell compiler that don’t do any code compaction since the value may be modified by another source

Ex:

volatile const int variable1 = 0;

int main()

{

printf(“variable1 %d\n”,variable1);

return 0;

}

2.Consider the following code snippet:

main()

{

int a,b;

a=foo();

b=foo()’

printf(“a=%d and b=%d”,a,b);

return(0);

}

you don’t know anything about function ‘foo’except it returns integer.

Are the values of a and b printed by printf function the same?If not can you give an example of function ‘foo’ which will cause a and b different?

Ex:

They need not be if the function is as follows

int foo()

{

int temp;

scanf(“%d”,&temp);

return(temp);

}

3.Given a word can you find all its anagrams? If you were asked to do this solutions only one word what would be your solution if it you were asked to find the anagrams for 10000 words would your solution change?

Ans:

(If any one of you know the solution please tell me)

but my solution would be maintain database of words in the language and search the combinations occurence.

4.What is complexity of searching an element in a

a) Linked list containing N elements

Ans: normally requires O(*n*) time (linear search).

b)Hash table containing N elements

Ans: log(n)

c)Binary search tree containing N elements

Ans: log(n)

d)A binary heap tree containing N elements

Ans: log(n)

e)A d-heap containing N elements

Ans: log(n)

5.Consider the following code snippet :

int find_fib(int N)

{

asser(N > 0);

int f1=1;

int f2=1;

if(N<2)

return(1);

return(find_fib(N-1)+find_fib(N-2));

}

given that find_fib is called from main with N as 25 how many total calls are made to find_fib?

Ans : 26

6. you are given an arry of 2n+1 integers. You are told that except one element all other elements have duplicate in the array? what is the time complexity of your solution?

Ans:

Sort the integers in ascending order and search element and search for the element so

1.Can you have both const and volatile qualifiers for single declaration in C? If so ,can you give me an example? If no, why not?

Ans: Yes we can have because if you want the value not to be changed by program and driver will change the value you can use this technique. Actually volatile qualifier is just to tell compiler that don’t do any code compaction since the value may be modified by another source

Ex:

volatile const int variable1 = 0;

int main()

{

printf(“variable1 %d\n”,variable1);

return 0;

}

2.Consider the following code snippet:

main()

{

int a,b;

a=foo();

b=foo()’

printf(“a=%d and b=%d”,a,b);

return(0);

}

you don’t know anything about function ‘foo’except it returns integer.

Are the values of a and b printed by printf function the same?If not can you give an example of function ‘foo’ which will cause a and b different?

Ex:

They need not be if the function is as follows

int foo()

{

int temp;

scanf(“%d”,&temp);

return(temp);

}

3.Given a word can you find all its anagrams? If you were asked to do this solutions only one word what would be your solution if it you were asked to find the anagrams for 10000 words would your solution change?

Ans:

(If any one of you know the solution please tell me)

but my solution would be maintain database of words in the language and search the combinations occurence.

4.What is complexity of searching an element in a

a) Linked list containing N elements

Ans: normally requires O(*n*) time (linear search).

b)Hash table containing N elements

Ans: log(n)

c)Binary search tree containing N elements

Ans: log(n)

d)A binary heap tree containing N elements

Ans: log(n)

e)A d-heap containing N elements

Ans: log(n)

5.Consider the following code snippet :

int find_fib(int N)

{

asser(N > 0);

int f1=1;

int f2=1;

if(N<2)

return(1);

return(find_fib(N-1)+find_fib(N-2));

}

given that find_fib is called from main with N as 25 how many total calls are made to find_fib?

Ans : 26

6. you are given an arry of 2n+1 integers. You are told that except one element all other elements have duplicate in the array? what is the time complexity of your solution?

Ans:

Sort the integers in ascending order and search element and search for the element so

1.Can you have both const and volatile qualifiers for single declaration in C? If so ,can you give me an example? If no, why not?

Ans: Yes we can have because if you want the value not to be changed by program and driver will change the value you can use this technique. Actually volatile qualifier is just to tell compiler that don’t do any code compaction since the value may be modified by another source

Ex:

volatile const int variable1 = 0;

int main()

{

printf(“variable1 %d\n”,variable1);

return 0;

}

2.Consider the following code snippet:

main()

{

int a,b;

a=foo();

b=foo()’

printf(“a=%d and b=%d”,a,b);

return(0);

}

you don’t know anything about function ‘foo’except it returns integer.

Are the values of a and b printed by printf function the same?If not can you give an example of function ‘foo’ which will cause a and b different?

Ex:

They need not be if the function is as follows

int foo()

{

int temp;

scanf(“%d”,&temp);

return(temp);

}

3.Given a word can you find all its anagrams? If you were asked to do this solutions only one word what would be your solution if it you were asked to find the anagrams for 10000 words would your solution change?

Ans:

(If any one of you know the solution please tell me)

but my solution would be maintain database of words in the language and search the combinations occurence.

4.What is complexity of searching an element in a

a) Linked list containing N elements

Ans: normally requires O(*n*) time (linear search).

b)Hash table containing N elements

Ans: log(n)

c)Binary search tree containing N elements

Ans: log(n)

d)A binary heap tree containing N elements

Ans: log(n)

e)A d-heap containing N elements

Ans: log(n)

5.Consider the following code snippet :

int find_fib(int N)

{

asser(N > 0);

int f1=1;

int f2=1;

if(N<2)

return(1);

return(find_fib(N-1)+find_fib(N-2));

}

given that find_fib is called from main with N as 25 how many total calls are made to find_fib?

Ans : 26

6. you are given an arry of 2n+1 integers. You are told that except one element all other elements have duplicate in the array? what is the time complexity of your solution?

Ans:

Sort the integers in ascending order and search element and search for the element so

Θ((2*n+1)*log*(2n+1)*)(sort) + n+1(search)

hey everybody under the sun i m humble here but willing to learn how to get free education grant or free student scholarhips tips from here !!

any tips guys ?

regards !

[…] C interview questions part 2 November 20091 comment 5 […]

Thank you for the auspicious writeup. It in fact was a amusement account it. Look advanced to more added agreeable from you! However, how could we communicate?

hi prasad,

nice reply. can you send c interview questions to my mail.

check at

gpv-buddha.blogspot.com

I m providin a link here for more C questions.

http://anujbansal1810.blogspot.com/2011/08/c-is-sea.html