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()
    {	
    char *p = "ayqm";
    printf("%c",++*(p++));
    }

    Answer:

    b
  2. main()
    	{
    	 int i=5;
    	 printf("%d",++i++);
    } 

    Answer:

    Compiler error: Lvalue required in function main

    Explanation:

    ++i yields an rvalue. For postfix ++ to operate an lvalue is required.
  3. main()
    {
    char *p = "ayqm";
    char c;
    c = ++*p++;
    printf("%c",c);
    }

    Answer:

    b

    Explanation:

    There is no difference between the expression ++*(p++) and ++*p++. Parenthesis just works as a visual clue for the reader to see which expression is first evaluated.
  4. int aaa() {printf("Hi");}
    int bbb(){printf("hello");}
    iny ccc(){printf("bye");}
    
    main()
    {
    int ( * ptr[3]) ();
    ptr[0] = aaa;
    ptr[1] = bbb;
    ptr[2] =ccc;
    ptr[2]();
    }

    Answer:

    bye

    Explanation:

    int (* ptr[3])() says that ptr is an array of pointers to functions that takes no arguments and returns the type int. By the assignment ptr[0] = aaa; it means that the first function pointer in the array is initialized with the address of the function aaa. Similarly, the other two array elements also get initialized with the addresses of the functions bbb and ccc. Since ptr[2] contains the address of the function ccc, the call to the function ptr[2]() is same as calling ccc(). So it results in printing "bye".
  5. main()
    {
    int i=5;
    printf("%d",i=++i ==6);
    }

    Answer:

    1

    Explanation:

    The expression can be treated as i = (++i==6), because == is of higher precedence than = operator. In the inner expression, ++i is equal to 6 yielding true(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.