Function Programming In C -Job Interview Frequently Asked Question and Answer Collection
http://ingenuitydias.blogspot.com/2015/08/function-programming-in-c-job-interview.html
Collection of most Frequently Asked Placement questions and Answers for Function and Pointer in C Programing in Practical viva in Engineering or Job interview for Hardware Programmer.
Variable Function Structure Pointer in C
Programming - C Viva Questions
Function in Embedded C
1. How to declare a pointer to a function?
a) Int *(fp)()
b) Int (*fp)()
c) Int * (fp)()
d) None
ANSWER: B
2. What is the difference between “extern int function_name();” and “int function_name();”
a) First is to access other function which is outside of the scope of program & second is to access the simple function.
b) First is to access the simple function & second is to access other function which is outside of the scope of program.
c) Both are same.
d) None.
ANSWER: B
3. How to declare an array of N pointers to functions returning pointers to functions returning pointers to characters?
a) Char *(*(*a[N])))
b) Char (*(*(*a[N])))
c) Char (*(*a[N]))
d) None
ANSWER: A
4. Can we declare a function that can return a pointer to a function of the same type?
a) Yes
b) No, we cannot do it directly
ANSWER: B
5. Function vprintf() uses the functionality of which header file?
a) Stadgs.h
b) Stdarg.h
c) Stdio.h
d) None
ANSWER: B
6. What does the error, invalid redeclaration of a function mean?
a) There is no declaration in scope,
b) There are multiple declarations
c) Function is invalid
d) None
ANSWER: A
7. Will C allow passing more or less arguments than required to a function?
a) If the prototype is not there then it will show “Too many or Too less arguments”.
b) If the prototype is around then it will show “Too many or Too less arguments”.
c) Sows simply compilation error
d) None
ANSWER: B
8. What is short-circuiting in C expressions?
a) If the left hand side is true for || or false for &&, the right hand side is not evaluated.
b) If the left hand side is true for + or false for &, the right hand side is not evaluated.
c) When two expressions in the syntax are same.
d) None.
ANSWER: A
9. What error would the following function give on compilation?
f( int a, int b)
{
Int a;
a=20;
return a;
}
a) Missing Parentheses in return statement
b) The function should be defined as int f(int a, int b)
c) Redecleration of a.
d) None.
ANSWER: C
10. How many times the following program would print ‘dododash’.
main()
{
printf(“\n dododash”);
main();
}
a) Infinite no of times
b) 32767 times
c) 65535 times
d) None
ANSWER: D
11. What are the correct syntaxes to send an array as a parameter to function?
a) func(array[size]);
b) func(*array);
c) func(&array);
d) func(array);
ANSWER: C & D
12. Mark the correct option.
#include<stdio.h>
Int main()
{
printf(“%p\n”, main());
return 0;
}
a) Print error
b) Print garbage value
c) Error :- main cannot called inside printf
d) Print nothing but runs infinitely.
ANSWER: D
13. How can one convert numbers to strings?
a) Using atoi()
b) Using printf()
c) Using sprint()
d) Using nsprintf()
ANSWER: C
14. What will be the output of the following code
main()
{
static int var = 5;
printf(“%d”, var- -);
if(var)
main();
}
a) Compilation error.
b) 55555
c) 54321
d) Infinite loop
ANSWER: C
15. Recursive functions are executed in which order
a) Parallel order
b) Iterative order
c) Last in first out
d) Random order
ANSWER: C
16. In recursive call of the function where the automatic variables are stored?
a) Stack
b) Queue
c) Array
d) Register
ANSWER: A
17. Will the following function gives output?
f1(int a, int b)
{
return ( f2(20) );
}
f2 (int a)
{
return (a * a);
}
a) Yes
b) No
ANSWER: A
18. If there is any problem in this code then find out
main()
{
int b;
b=f(30);
printf(“%d”, b);
}
int f (int a)
{
a > 30 ? return(10) : return(30);
}
a) Problem with int f( int a)
b) Problem with return
c) Both
d) None
ANSWER: B
19. Usually the loop’s working is faster than recursion
a) Always true
b) Always false
c) Sometimes true
d) Sometimes false
ANSWER: A
20. If there is any mistake then add code and remove it
main()
{
int a;
a = f(20, 6.28);
printf(“%d”, a);
}
f(int aa, float bb)
{
return((float)aa+bb);
}
a) Add float f(int , float) before printf
b) Add float f(int , float) after printf
c) Add float f(int , float)
d) None
ANSWER: C
21. Can you use the fprintf() to display the output on the screen?
Yes
No
ANSWER: Yes
22. The function that calls itself for its processing is known as.
Inline Function
Nested Function
Overloaded Function
Recursive Function
ANSWER: Recursive Function
23. In C, if you pass an array as an argument to a function, what actually gets passed?
Value of elements in array
First element of the array
Base address of the array
Address of the last element of array
ANSWER: Base address of the array
24. The library function used to find the last occurrence of a character in a string is
strnstr()
laststr()
strrchr()
strstr()
ANSWER: strrchr()
25. Who calls to the function main()
kernel
operating system
cpu
ALU
ANSWER: operating system
Variable Function Structure Pointer in C
Programming - C Viva Questions
Function in Embedded C
1. How to declare a pointer to a function?
a) Int *(fp)()
b) Int (*fp)()
c) Int * (fp)()
d) None
ANSWER: B
2. What is the difference between “extern int function_name();” and “int function_name();”
a) First is to access other function which is outside of the scope of program & second is to access the simple function.
b) First is to access the simple function & second is to access other function which is outside of the scope of program.
c) Both are same.
d) None.
ANSWER: B
3. How to declare an array of N pointers to functions returning pointers to functions returning pointers to characters?
a) Char *(*(*a[N])))
b) Char (*(*(*a[N])))
c) Char (*(*a[N]))
d) None
ANSWER: A
4. Can we declare a function that can return a pointer to a function of the same type?
a) Yes
b) No, we cannot do it directly
ANSWER: B
5. Function vprintf() uses the functionality of which header file?
a) Stadgs.h
b) Stdarg.h
c) Stdio.h
d) None
ANSWER: B
6. What does the error, invalid redeclaration of a function mean?
a) There is no declaration in scope,
b) There are multiple declarations
c) Function is invalid
d) None
ANSWER: A
7. Will C allow passing more or less arguments than required to a function?
a) If the prototype is not there then it will show “Too many or Too less arguments”.
b) If the prototype is around then it will show “Too many or Too less arguments”.
c) Sows simply compilation error
d) None
ANSWER: B
8. What is short-circuiting in C expressions?
a) If the left hand side is true for || or false for &&, the right hand side is not evaluated.
b) If the left hand side is true for + or false for &, the right hand side is not evaluated.
c) When two expressions in the syntax are same.
d) None.
ANSWER: A
9. What error would the following function give on compilation?
f( int a, int b)
{
Int a;
a=20;
return a;
}
a) Missing Parentheses in return statement
b) The function should be defined as int f(int a, int b)
c) Redecleration of a.
d) None.
ANSWER: C
10. How many times the following program would print ‘dododash’.
main()
{
printf(“\n dododash”);
main();
}
a) Infinite no of times
b) 32767 times
c) 65535 times
d) None
ANSWER: D
11. What are the correct syntaxes to send an array as a parameter to function?
a) func(array[size]);
b) func(*array);
c) func(&array);
d) func(array);
ANSWER: C & D
12. Mark the correct option.
#include<stdio.h>
Int main()
{
printf(“%p\n”, main());
return 0;
}
a) Print error
b) Print garbage value
c) Error :- main cannot called inside printf
d) Print nothing but runs infinitely.
ANSWER: D
13. How can one convert numbers to strings?
a) Using atoi()
b) Using printf()
c) Using sprint()
d) Using nsprintf()
ANSWER: C
14. What will be the output of the following code
main()
{
static int var = 5;
printf(“%d”, var- -);
if(var)
main();
}
a) Compilation error.
b) 55555
c) 54321
d) Infinite loop
ANSWER: C
15. Recursive functions are executed in which order
a) Parallel order
b) Iterative order
c) Last in first out
d) Random order
ANSWER: C
16. In recursive call of the function where the automatic variables are stored?
a) Stack
b) Queue
c) Array
d) Register
ANSWER: A
17. Will the following function gives output?
f1(int a, int b)
{
return ( f2(20) );
}
f2 (int a)
{
return (a * a);
}
a) Yes
b) No
ANSWER: A
18. If there is any problem in this code then find out
main()
{
int b;
b=f(30);
printf(“%d”, b);
}
int f (int a)
{
a > 30 ? return(10) : return(30);
}
a) Problem with int f( int a)
b) Problem with return
c) Both
d) None
ANSWER: B
19. Usually the loop’s working is faster than recursion
a) Always true
b) Always false
c) Sometimes true
d) Sometimes false
ANSWER: A
20. If there is any mistake then add code and remove it
main()
{
int a;
a = f(20, 6.28);
printf(“%d”, a);
}
f(int aa, float bb)
{
return((float)aa+bb);
}
a) Add float f(int , float) before printf
b) Add float f(int , float) after printf
c) Add float f(int , float)
d) None
ANSWER: C
21. Can you use the fprintf() to display the output on the screen?
Yes
No
ANSWER: Yes
22. The function that calls itself for its processing is known as.
Inline Function
Nested Function
Overloaded Function
Recursive Function
ANSWER: Recursive Function
23. In C, if you pass an array as an argument to a function, what actually gets passed?
Value of elements in array
First element of the array
Base address of the array
Address of the last element of array
ANSWER: Base address of the array
24. The library function used to find the last occurrence of a character in a string is
strnstr()
laststr()
strrchr()
strstr()
ANSWER: strrchr()
25. Who calls to the function main()
kernel
operating system
cpu
ALU
ANSWER: operating system
Thanks for your appreciation.Our readers would b e benefited by information provided by you on your site.
ReplyDelete