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[ ]="%d\n";
    p[1] = 'c';
    printf(p,65);
    }

    Answer:

    A

    Explanation:

    Due to the assignment p[1] = 'c' the string becomes, "%c\n". Since this string becomes the format string for printf and ASCII value of 65 is 'A', the same gets printed.
  2. void ( * abc( int, void ( *def) () ) ) ();

    Answer:

    abc is a ptr to a function which takes 2 parameters (a) an integer variable (b)a ptrto a funtion which returns void. the return type of the function is void.

    Explanation:

    Apply the clock-wise rule to find the result.
  3. main()
    {
    while (strcmp("some","some\0")) 
    printf("Strings are not equal\n");
    	}

    Answer:

    No output

    Explanation:

    Ending the string constant with \0 explicitly makes no difference. So "some" and "some\0" are equivalent. So, strcmp returns 0 (false) hence breaking out of the while loop.
  4. main()
    {
    char str1[] = {'s','o','m','e'};
    char str2[] = {'s','o','m','e','\0'};
    while (strcmp(str1,str2)) 
    printf("Strings are not equal\n");
    }

    Answer:

    "Strings are not equal"
    "Strings are not equal" ...

    Explanation:

    If a string constant is initialized explicitly with characters, '\0' is not appended automatically to the string. Since str1 doesn't have null termination, it treats whatever the values that are in the following positions as part of the string until it randomly reaches a '\0'. So str1 and str2 are not the same, hence the result.
  5. main()
    {
    int i = 3;
    for (;i++=0;) printf("%d",i);
    }

    Answer:

    Compiler Error: Lvalue required.

    Explanation:

    As we know that increment operators return rvalues and hence it cannot appear on the left hand side of an assignment operation.

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