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=3;
          char name[]="hello";
     };
    struct xx *s;
    printf("%d",s->x);
    printf("%s",s->name);
    }

    Answer:

    Compiler Error

    Explanation:

    You should not initialize variables in declaration
  2. #include‹stdio.h›
    main()
    {
    struct xx
    {
    int x;
    struct yy
    {
    char s;
    	struct xx *p;
    };
    struct yy *q;
    };
    }
    Answer:
    Compiler Error

    Explanation:

    The structure yy is nested within structure xx. Hence, the elements are of yy are to be accessed through the instance of structure xx, which needs an instance of yy to be known. If the instance is created after defining the structure the compiler will not know about the instance relative to xx. Hence for nested structure yy you have to declare member.
  3. main()
    {
    printf("\nab");
    printf("\bsi");
    printf("\rha");
    }

    Answer:

    hai

    Explanation:

    \n - newline
    \b - backspace
    \r - linefeed
  4. main()
    {
    int i=5;
    printf("%d%d%d%d%d%d",i++,i--,++i,--i,i);
    }

    Answer:

    45545

    Explanation:

    The arguments in a function call are pushed into the stack from left to right. The evaluation is by popping out from the stack. and the evaluation is from right to left, hence the result.
  5. #define square(x) x*x
    main()
    {
    int i;
    i = 64/square(4);
    printf("%d",i);
    }

    Answer:

    64
    Explanation:
    the macro call square(4) will substituted by 4*4 so the expression becomes i = 64/4*4 . Since / and * has equal priority the expression will be evaluated as (64/4)*4 i.e. 16*4 = 64

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