C Functions Questions and Answers

Practice Mode
Showing 10 of 151 questions
Q41
Char var1 [10]; char var2 [5] = "Angel"; strcpy (var1, Var2); What will happen when the above code is executed ?
  • A The linker will reject this as an array overflow error.
  • B The variable var1 and var2 will contain the string "Angel" and no problems will occur.,
  • C The compiler will reject it because only string pointers can be initialized this way.
  • D The variable var2 will contain the word "Angel", but the behaviour of strcpy is undefined.
Answer: Option D
Q42
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?
  • A int list [] [2]
  • B int list [2][2]
  • C int (*list)[2]
  • D int *list [2]
Answer: Option D
Q43
What does strncat append to  the target string after the specified number of characters have been copied ?
  • A Nothing
  • B NULL
  • C \0
  • D -0
Answer: Option C
Q44
INT STRCMP (S1, S2) compares strings s1 and s2 and
  • A returns a value less than zero if s2 is lexicographically greater than s1
  • B retusns zero if s1 is lexicographically less than s2.
  • C returns 1 if s1 is equal to s2.
  • D returns a value less than zero if s1 is lexicographically greater than s2.
Answer: Option A
Q45
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 ?
  • A sv = info ;
  • B strncpy (sv, info, sizeof (info));
  • C strncpy (sv, info, strlen (info) + 1);
  • D strncpy (sv, info, strlen (sv)
Answer: Option C
Q46
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 ?
  • A return (x = (y=2) *z+(a|b)* (2+s));
  • B return (x=((y=2) * z + (a|b) * (x+s)));
  • C return x=(y=2) * z + a |b * (2 +s));
  • D return x= (y=2) *z+(a/b) * (2+s);
Answer: Option B
Q47
When a function is recursively called all automatic variables are
  • A stored in stack
  • B stored in queue
  • C stored in array
  • D stored in linked list
Answer: Option A
Q48
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?
  • A 1
  • B infinity
  • C zero
  • D 10
Answer: Option C
Q49
C allows
  • A only call by value
  • B only call by reference
  • C both
  • D only call by value and sometimesl call by reference.
Answer: Option A
Q50
main ( ) { } int a ; f1 ( ) { } f2 ( ) { } Two which of the above function, is int a available for ?
  • A all of them
  • B only f2
  • C only f1
  • D f1 and f2 only
Answer: Option D
Questions and Answers for Competitive Exams Various Entrance Test