C- Functions Question and Answer

C- Functions Question and Answer
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.
Show Answer
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]
Show Answer
43. What does strncat append to  the target string after the specified number of characters have been copied ?
  • Nothing
  • NULL
  • \0
  • -0
Show Answer
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.
Show Answer
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)
Show Answer
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);
Show Answer
47. When a function is recursively called all automatic variables are
  • stored in stack
  • stored in queue
  • stored in array
  • stored in linked list
Show Answer
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
Show Answer
49. C allows
  • only call by value
  • only call by reference
  • both
  • only call by value and sometimesl call by reference.
Show Answer
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
Show Answer
Questions and Answers for Competitive Exams Various Entrance Test