C- Functions Question and Answer
C- Functions Question and Answer
131. Which of the following data structure used in function recursion.
- Stack
- Queue
- Tree
- None of the above
132. When variable are push into the function frame address of variable are
- Growing up
- Growing down
- Growing left
- Growing right
133. When variables are push into stack, that stack pointer (SP) growing
- Up
- Down
- Left
- Right
134. Find the output
int n=0, R;
void main ( )
{
R=0;
printf("%d %d", fun (n), R);
}
int fun (int n)
{
if (n>3)
return R=5;
R=6;
return (1);
}
int n=0, R;
void main ( )
{
R=0;
printf("%d %d", fun (n), R);
}
int fun (int n)
{
if (n>3)
return R=5;
R=6;
return (1);
}
- 1 6
- 1 6
- 1 0
- 1 5
135. Find the output
static int c;
void f(int n)
{
int i;
for (i =1; i<=n;i++)
f (n-i);
c++;
}
void main ( )
{
extern int c;
f (5);
printf ("%d",c);
}
static int c;
void f(int n)
{
int i;
for (i =1; i<=n;i++)
f (n-i);
c++;
}
void main ( )
{
extern int c;
f (5);
printf ("%d",c);
}
- 32
- 22
- 35
- 45
136. Find the output
void fun (int, int*);
void main ( )
{
int j, i=5;
int *inptr;
intptr=&j;
j=i;
printf("%d %d", i, j);
fun (j, intptr);
printf(" %d %d", i, j);
}
void fun ( int k, int *iptr)
{
k++;
(*iptr) ++;
return;
}
void fun (int, int*);
void main ( )
{
int j, i=5;
int *inptr;
intptr=&j;
j=i;
printf("%d %d", i, j);
fun (j, intptr);
printf(" %d %d", i, j);
}
void fun ( int k, int *iptr)
{
k++;
(*iptr) ++;
return;
}
- 5 5 5 6
- 5 5 6 6
- 5 6 5 6
- 5 5 6 5
137. Find the output
void main ( )
{
int i=4;
if (i>5)
printf ("Hi");
else
f(i);
}
f (int j)
{
if (j>=4) f(j-1);
else if (j==0)return;
printf ("%d",j);
return;
}
void main ( )
{
int i=4;
if (i>5)
printf ("Hi");
else
f(i);
}
f (int j)
{
if (j>=4) f(j-1);
else if (j==0)return;
printf ("%d",j);
return;
}
- 23
- 34
- 45
- 67
138. Find the output
int *NEXT (register nt i)
{
char *ipt;
ipt=&i;
ipt++;
*ipt=1;
return ipt;
}
int j=1;
printf("%d", *(NEXT (J)));
}
int *NEXT (register nt i)
{
char *ipt;
ipt=&i;
ipt++;
*ipt=1;
return ipt;
}
int j=1;
printf("%d", *(NEXT (J)));
}
- 0
- 1
- 11
- 257
139. Find the output
funct ( char* str)
{
printf ("%s", str);
}
void main( )
{
static int ii=1;
int jj=5;
ii+=++jj;
funct(ii++"Campus Intervies");
}
funct ( char* str)
{
printf ("%s", str);
}
void main( )
{
static int ii=1;
int jj=5;
ii+=++jj;
funct(ii++"Campus Intervies");
}
- Campus Interview
- Interview
- nterview
- s interview
140. Find the output
funct (str)
{
printf("%s", str);
}
void main ( )
{
funct('-'-'-'+"CIMPLE");
}
funct (str)
{
printf("%s", str);
}
void main ( )
{
funct('-'-'-'+"CIMPLE");
}
- CIMPLE
- Garbage
- --CIMPLE
- Compilation error