Sample Questions Best site for GRE, LSAT, SAT, GMAT, TOEFL, CCNA, CCSA and interview sample questions  

Technical Sample Questions : C |  C++ |  Oracle |  Java | Unix |  Operating Systems |  Data Structure

Sample Technical Questions

C Sample Question

  1. void main()
    {
    int *mptr, *cptr;
    mptr = (int*)malloc(sizeof(int));
    printf("%d",*mptr);
    int *cptr = (int*)calloc(sizeof(int),1);
    printf("%d",*cptr);
    }

    Answer:

    garbage-value 0

    Explanation:

    The memory space allocated by malloc is uninitialized, whereas calloc returns the allocated memory space initialized to zeros.
  2. void main()
    {
    static int i;
    while(i<=10)
    (i>2)?i++:i--;
    	printf("%d", i);
    }

    Answer:

    32767

    Explanation:

    Since i is static it is initialized to 0. Inside the while loop the conditional operator evaluates to false, executing i--. This continues till the integer value rotates to positive value (32767). The while condition becomes false and hence, comes out of the while loop, printing the i value.
  3. main()
    {
    		int i=10,j=20;
    	j = i, j?(i,j)?i:j:j;
    		printf("%d %d",i,j);
    }

    Answer:

    10 10

    Explanation:

    The Ternary operator ( ? : ) is equivalent for if-then-else statement. So the question can be written as:
    if(i,j)
    	   	     {
    if(i,j)
    		     j = i;
    		else
    		    j = j;			
    		}
    	   else
    		j = j;

    1. const char *a;
    2. char* const a;
    3. char const *a;

    -Differentiate the above declarations.

    Answer:

    1. 'const' applies to char * rather than 'a' ( pointer to a constant char )
      *a='F' : illegal
      a="Hi" : legal
    2. 'const' applies to 'a' rather than to the value of a (constant pointer to char )
      *a='F' : legal
      a="Hi" : illegal
    3. Same as 1.
  4. main()
    {
    		int i=5,j=10;
    	i=i&=j&&10;
    		printf("%d %d",i,j);
    }

    Answer:

    1 10

    Explanation:

    The expression can be written as i=(i&=(j&&10)); The inner expression (j&&10) evaluates to 1 because j==10. i is 5. i = 5&1 is 1. Hence the result.

« Previous || Next »

C Sample Question Number : 1-3 | 4-7 | 8-11 | 12-16 | 17-21 | 22-25 | 26-30 | 31-35 | 36-40 | 41-45 | 46-48 | 49-52 | 53-59 | 60-64 | 65-69 | 70-74 | 75-79 | 80-83 | 84-87 | 88-91 | 92-95 | 96-100 | 101-105 | 106-110 | 111-115 | 116-120 | 121-125 | 126-130 | 131-135 | 136-140 | 141-145 | 146-150

Sample Test Questions
GRE Sample Questions
CAT Sample Questions
GMAT Sample Questions
TOEFL Sample Questions
ACT Sample Questions
SAT Sample Questions
LSAT Sample Questions
PSAT Sample Questions
MCAT Sample Questions
PMP Sample Questions
GED Sample Questions
ECDL Sample Questions
DMV Sample Questions
CCNA Sample Questions
MCSE Sample Questions
Network+ Sample Questions
A+ Sample Questions
Technical Sample Questions
WASL Sample Questions
CISA Sample Questions

Other Sample Questions
Sample Interview Questions
Sample Teacher Interview Questions
Sample Citizenship Questions
Accuplacer Sample Questions
Science Bowl sample Questions
Driving Test Sample Questions
Sample Survey Questions Sample Essay Questions
Sample Behavioral Interview Questions

Copyright © 2004-2013, Best BSQ. All Rights Reserved.