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 :

Click on Discuss to view users comments.

Write your comments here:



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 :

Click on Discuss to view users comments.

Write your comments here:



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.

Click on Discuss to view users comments.

Write your comments here:



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.

Click on Discuss to view users comments.

Write your comments here:



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.

Click on Discuss to view users comments.

Write your comments here: