C- Functions Question and Answer

C- Functions Question and Answer
141. Find the output
void call (int);
void main ()
{
call (3);
}
void call (int a)
{
if (a<6)
call (++a);
printf("%d",a);
}

  • 4 5 6
  • 6 5 4 3
  • 6 6 5 4
  • 5 5 4
Show Answer
142. Find the output
void func( )
}
printf("Function");
}
void main ( )
{
void main ( )
{
func;
func ( );
}

  • Function
  • Function
  • Compilation error
  • None of these
Show Answer
143. Which functions are used to mapping program from user area to kernel area.
  • Standard Library function
  • User defined function
  • System call cunction
  • None of the above
Show Answer
144. Find the output
int i;
int increment (int i)
{
i++ -2;
return;
}
int main ( )
{
for (i=2; increment (i);)
{
if (i>0)
break;
}
printf("%d\n",i);
return 0;
}
  • 1
  • 2
  • iniinite loop
  • Compilation error
Show Answer
145. Find the output
void fun(int [ ] [3]);
void main( )
{
int a[3] [3]={1 , 2, 3}
{4, 5, 6), {7, 8, 9}};
fun (a);
printf("%d", a[2] [1]);
}
void fun( int b [ ] [3])
{
++b;
b[1+0] [1%2]= -9;
}


  • -8
  • -9
  • 9
  • Compilation error
Show Answer
146. Find the output
void main ( )
{
static int val=7;
int data;
if (--val)
{
data=main( )+val;
printf(%d ", data);
}
return 0;
}
  • 1 2 3 4 5 6
  • 0 0 0 0 0 0
  • INFINITE LOOP
  • Compilation error
Show Answer
147. Which of the following three functions are likely to cause problem with pointers
int *f1(void)
{
int x=10;
return (&x);
}
int *f2(void)
{
int *ptr;
*ptr=10;
return ptr;
}
int *f3(void)
{
int *ptr;
ptr=(int*) malloc(sizeof (int));
return ptr;
}

  • only f3
  • only f1 and f3
  • only f1 and f2
  • f1, f2, f3
Show Answer
148. Find the output
void main ( )
{
int a,b;
a=sd (123);
b=sd (123);
printf("%d %d",a,b);
}
sd (int n)
{
static int s=0;
int d;
if (n!0);
{
d=n%10;
n=(n-d)/10;
s=s+d;
sd(n);
}
else
return (s);
}

  • 12 6
  • 6 12
  • 3 15
  • Compilation error
Show Answer
149. Which register holds the base address of the function frame
  • AX
  • CX
  • SI
  • BP
Show Answer
150. Find the output
void fun (char**);
void main()
{
har *argv [ ]={"ab", "cd" "er", "gh", "ij", "k1");
fun (argv);
}
void fun (char **p)
{
char *t;
{
char *t;
t=(p+=sizeof (int)) [-1];
printf("%s", t);
}


  • ab
  • cd
  • ef
  • gh
Show Answer
Questions and Answers for Competitive Exams Various Entrance Test