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=1;
        while (i<=5)
        {
           printf("%d",i);
           if (i>2)
    	  goto here;
           i++;
        }
    }
    fun()
    {
       here:
         printf("PP");
    }

    Answer:

    Compiler error: Undefined label 'here' in function main

    Explanation:

    Labels have functions scope, in other words The scope of the labels is limited to functions . The label 'here' is available in function fun() Hence it is not visible in function main.
  2. main()
    {
       static char names[5][20]={"pascal","ada","cobol","fortran","perl"};
        int i;
        char *t;
        t=names[3];
        names[3]=names[4];
        names[4]=t;	
        for (i=0;i<=4;i++)
        	printf("%s",names[i]);
    }

    Answer:

    Compiler error: Lvalue required in function main

    Explanation:

    Array names are pointer constants. So it cannot be modified.
  3. void main()
    {
    	int i=5;
    	printf("%d",i++ + ++i);
    }

    Answer:

    Output Cannot be predicted exactly.

    Explanation:

    Side effects are involved in the evaluation of i
  4. void main()
    {
    	int i=5;
    	printf("%d",i+++++i);
    }

    Answer:

    Compiler Error

    Explanation:

    The expression i+++++i is parsed as i ++ ++ + i which is an illegal combination of operators.
  5. #include‹stdio.h›
    main()
    {
    int i=1,j=2;
    switch(i)
     {
     case 1:  printf("GOOD");
    	    break;
     case j:  printf("BAD");
      	   break;
     }
    }

    Answer:

    Compiler Error: Constant expression required in function main.

    Explanation:

    The case statement can have only constant expressions (this implies that we cannot use variable names directly so an error).

    Note:

    Enumerated types can be used in case statements.

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