C Programming Questions and Answer
Posted by Samath
Last Updated: March 01, 2012
  966

What will happen if in a C program you assign a value to anarray element whose subscript exceeds the size of array?

A.            Theelement will be set to 0.

B.            Thecompiler would report an error.

C.            Theprogram may crash if some important data gets overwritten.

D.            The arraysize would appropriately grow

 

What does the following declaration mean?

int (*ptr)[10];

A.            ptr isarray of pointers to 10 integers

B.            ptr is apointer to an array of 10 integers

C.            ptr is anarray of 10 integers

D.            ptr is anpointer to array

 

In C, if you pass an array as an argument to a function,what actually gets passed?

A.            Value ofelements in array

B.            Firstelement of the array

C.            Baseaddress of the array

D.            Addressof the last element of array

 

Which of the following is the correct order of evaluationfor the below expression?

z = x + y * z / 4 % 2 - 1

A.            * / % + -=            B.            = * / % + -

C.            / * % - +=            D.            * % / - + =

 

 

Which of the following correctly shows the hierarchy ofarithmetic operations in C?

A.            / + * -    B.            *- / +

C.            + - / *    D.            /* + -

 

               

Which of the following is the correct usage of conditionaloperators used in C?

A.            a>b ?c=30 : c=40;                            B.           a>b ? c=30;

C.            max =a>b ? a>c?a:c:b>c?b:c       D.            return (a>b)?(a:b)

 

               

Which of the following is the correct order if callingfunctions in the below code?

a = f1(23, 14) * f2(12/4) + f3();

A.            f1, f2,f3

B.            f3, f2,f1

C.            Order mayvary from compiler to compiler

D.            None ofabove

 

               

Which of the following are unary operators in C?

1.            !

2.            sizeof

3.            ~

4.            &&

A.            1, 2         B.            1,3

C.            2, 4         D.            1,2, 3

   
  
 
 
   

 
 
Come on programmers. Lets see what you'll got
 
Great practice question!