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. main()
    {
    		int i=4,j=7;
    	j = j || i++ && printf("YOU CAN");
    		printf("%d %d", i, j);
    }

    Answer:

    4 1

    Explanation:

    The boolean expression needs to be evaluated only till the truth value of the expression is not known. j is not equal to zero itself means that the expression's truth value is 1. Because it is followed by || and true || (anything) => true where (anything) will not be evaluated. So the remaining expression is not evaluated and so the value of i remains the same. Similarly when && operator is involved in an expression, when any of the operands become false, the whole expression's truth value becomes false and hence the remaining expression will not be evaluated.
    false && (anything) => false where (anything) will not be evaluated.
  2. main()
    {
    		register int a=2;
    	printf("Address of a = %d",&a);
    		printf("Value of a   = %d",a);
    }

    Answer:

    Compier Error: '&' on register variable
    Rule to Remember:
    & (address of ) operator cannot be applied on register variables.
  3. main()
    {
    		float i=1.5;
    	switch(i)
    		{
    		case 1: printf("1");
    			case 2: printf("2");
    			default : printf("0");
    	}
    }

    Answer: Compiler Error: switch expression not integral

    Explanation: Switch statements can be applied only to integral types.

  4. main()
    {	
    		extern i;
    	printf("%d\n",i);
    		{
    			int i=20;
    		printf("%d\n",i);
    		}
    }

    Answer:

    Linker Error : Unresolved external symbol i

    Explanation:

    The identifier i is available in the inner block and so using extern has no use in resolving it.
  5. main()
    {
    		int a=2,*f1,*f2;
    	f1=f2=&a;
    		*f2+=*f2+=a+=2.5;
    	printf("\n%d %d %d",a,*f1,*f2);
    }

    Answer:

    16 16 16

    Explanation:

    f1 and f2 both refer to the same memory location a. So changes through f1 and f2 ultimately affects only the value of a.

« 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.