C Functions Questions and Answers
C Functions Questions with Answers provide an in-depth look at one of the most fundamental concepts in C programming. Understanding how to define, call, and manage user-defined and library functions is key to mastering structured programming. These C programming MCQs are widely used in technical interviews and coding tests conducted by companies like TCS, Wipro, and Infosys. Each question includes explanations to help you grasp parameter passing, recursion, return types, and scope. Practicing programming questions with answers strengthens your coding logic and prepares you for real-world software challenges. Download C programming MCQ PDFs and practice online to enhance your technical aptitude efficiently.
C Functions
Showing 10 of
151 questions
41. Char var1 [10]; char var2 [5] = "Angel"; strcpy (var1, Var2); What will happen when the above code is executed ?
- The linker will reject this as an array overflow error.
- The variable var1 and var2 will contain the string "Angel" and no problems will occur.,
- The compiler will reject it because only string pointers can be initialized this way.
- The variable var2 will contain the word "Angel", but the behaviour of strcpy is undefined.
42. void display (????) { printf(%d\n, list [1] [0]); } int main ( ) { int ary [2] [2] = (1, 2, 3, 4); display (void * ) ry ); return 0; } Which of the following when substituted for the ???? above, will NOT correctly print out the number 3?
- int list [] [2]
- int list [2][2]
- int (*list)[2]
- int *list [2]
43. What does strncat append to the target string after the specified number of characters have been copied ?
- Nothing
- NULL
- \0
- -0
44. INT STRCMP (S1, S2) compares strings s1 and s2 and
- returns a value less than zero if s2 is lexicographically greater than s1
- retusns zero if s1 is lexicographically less than s2.
- returns 1 if s1 is equal to s2.
- returns a value less than zero if s1 is lexicographically greater than s2.
45. int func ( char *sv) { static char info [ ] = "If anything can go wrong , it will"; ???? } from the sample above, which of the following could replace the ???? to correctly copy text from info into the passed buffer without any illegal memory accesses ?
- sv = info ;
- strncpy (sv, info, sizeof (info));
- strncpy (sv, info, strlen (info) + 1);
- strncpy (sv, info, strlen (sv)
46. return (x = (((y = 2) *z + ((a|b) * (2+s))))); Which of the following expressions use he minimum number of parentheses and is equivalent to the expression above ?
- return (x = (y=2) *z+(a|b)* (2+s));
- return (x=((y=2) * z + (a|b) * (x+s)));
- return x=(y=2) * z + a |b * (2 +s));
- return x= (y=2) *z+(a/b) * (2+s);
47. When a function is recursively called all automatic variables are
- stored in stack
- stored in queue
- stored in array
- stored in linked list
48. main ( ) { int n = 10; fun (n); } int fun ( int n) { int i; for (i=0, i<=n; i++) fun (n-i); printf(" Kodeeswaran"); } How many times is the printf statement executed for n=10?
- 1
- infinity
- zero
- 10
49. C allows
- only call by value
- only call by reference
- both
- only call by value and sometimesl call by reference.
50. main ( ) { } int a ; f1 ( ) { } f2 ( ) { } Two which of the above function, is int a available for ?
- all of them
- only f2
- only f1
- f1 and f2 only