Classical

C Programming MCQ - Functions & Recursion

21:  

 void can be used

A.

 as a data-type of a function that returns nothing to its calling environment

B.

inside the brackets of a function that does not need any argument

C.

in an expression

D.

both (a) & (b)

 
 

Option: D

Explanation :


22:  

 Any C program

A.

must contain at least one function

B.

need not contain any function

C.

needs input data

D.

none of the above

 
 

Option: A

Explanation :


23:  

The following program

main ()
{ int  a = 4;
   change { a };
   printf ("%d", a);
}
change (a)
int a;
{
printf("%d", ++a);
}

outputs

A.

55

B.

45

C.

54

D.

44

 
 

Option: C

Explanation :

change (a) , prints 5 but the value of 'a' in main ( ) is still 4. So main( ) will print 4.


24:  

The following program
 main()
{
inc(); inc(); inc();
}
inc()
{
static int x;
printf("%d", ++x);
}

A.

prints 012

B.

prints 123

C.

prints 3 consecutive, but unpredictable numbers

D.

prints 111

 
 

Option: B

Explanation :

By default x will be initialized to 0. Since its storage class is static, it presents its exit value ( and forbids reinitialization on re-entry ). So, 123 will be printed.


25:  

The following program
main()
{
int abc();
abc ();
( *abc) (); 
}
int abc( )
{
printf ("come");
}

A.

results in a compilation error

B.

prints come come

C.

results in a run time

D.

prints come    come

 
 

Option: B

Explanation :

The function abc can be invoked as abc( ) or ( *abc ) ( ). Both are two different ways of doing the same thing.




Suggest an improvement