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. #include‹stdio.h›
    main()
    {
    struct xx
     {
    	  int x;
    	  struct yy
    	   {
    	     char s;
    	     struct xx *p;
    	   };
                	 struct yy *q;
               	 };
              	}

    Answer:

    Compiler Error

    Explanation:

    in the end of nested structure yy a member have to be declared.
  2. main()
    {
     extern int i;
     i=20;
     printf("%d",sizeof(i));
    }

    Answer:

    Linker error: undefined symbol '_i'.

    Explanation:

    extern declaration specifies that the variable i is defined somewhere else. The compiler passes the external variable to be resolved by the linker. So compiler doesn't find an error. During linking the linker searches for the definition of i. Since it is not found the linker flags an error.
  3. main()
    {
    printf("%d", out);
    }
    int out=100;

    Answer:

    Compiler error: undefined symbol out in function main.

    Explanation:

    The rule is that a variable is available for use from the point of declaration. Even though a is a global variable, it is not available for main. Hence an error.
  4. main()
    {
     extern out;
     printf("%d", out);
    }
     int out=100;

    Answer:

    100

    Explanation:

    This is the correct way of writing the previous program.
  5. main()
    {
     show();
    }
    void show()
    {
     printf("I'm the greatest");
    }

    Answer:

    Compier error: Type mismatch in redeclaration of show.

    Explanation:

    When the compiler sees the function show it doesn't know anything about it. So the default return type (ie, int) is assumed. But when compiler sees the actual definition of show mismatch occurs since it is declared as void. Hence the error.
    The solutions are as follows:
    1. declare void show() in main() .
    2. define show() before main().
    3. declare extern void show() before the use of show().

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