C Function - Placement questions and answers

C Function - Placement questions and answers


1. How to declare a pointer to a function?

a) Int *(fp)()
b) Int (*fp)()
c) Int * (fp)()
d) None

View Answer / Hide Answer

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.

View Answer / Hide Answer

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

View Answer / Hide Answer

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

View Answer / Hide Answer

ANSWER: B




5. Function vprintf() uses the functionality of which header file?

a) Stadgs.h
b) Stdarg.h
c) Stdio.h
d) None

View Answer / Hide Answer

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

View Answer / Hide Answer

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

View Answer / Hide Answer

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.

View Answer / Hide Answer

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.

View Answer / Hide Answer

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

View Answer / Hide Answer

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);

View Answer / Hide Answer

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.

View Answer / Hide Answer

ANSWER: D




13. How can one convert numbers to strings?

a) Using atoi()
b) Using printf()
c) Using sprint()
d) Using nsprintf()

View Answer / Hide Answer

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

View Answer / Hide Answer

ANSWER: C




15. Recursive functions are executed in which order

a) Parallel order
b) Iterative order
c) Last in first out
d) Random order

View Answer / Hide Answer

ANSWER: C




16. In recursive call of the function where the automatic variables are stored?

a) Stack
b) Queue
c) Array
d) Register

View Answer / Hide Answer

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

View Answer / Hide Answer

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

View Answer / Hide Answer

ANSWER: B




19. Usually the loop’s working is faster than recursion

a) Always true
b) Always false
c) Sometimes true
d) Sometimes false

View Answer / Hide Answer

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

View Answer / Hide Answer

ANSWER: C


Post your comment