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›
    int one_d[]={1,2,3};
    main()
    {
     int *ptr; 
     ptr=one_d;
     ptr+=3;
     printf("%d",*ptr);
    }

    Answer:

    garbage value

    Explanation:

    ptr pointer is pointing to out of the array range of one_d.
  2. # include‹stdio.h›
    aaa() {
      printf("hi");
     }
    bbb(){
     printf("hello");
     }
    ccc(){
     printf("bye");
     }
    main()
    {
      int (*ptr[3])();
      ptr[0]=aaa;
      ptr[1]=bbb;
      ptr[2]=ccc;
      ptr[2]();
    }

    Answer:

    bye

    Explanation:

    ptr is array of pointers to functions of return type int.ptr[0] is assigned to address of the function aaa. Similarly ptr[1] and ptr[2] for bbb and ccc respectively. ptr[2]() is in effect of writing ccc(), since ptr[2] points to ccc.
  3. #include‹stdio.h›
    main()
    {
    FILE *ptr;
    char i;
    ptr=fopen("zzz.c","r");
    while((i=fgetch(ptr))!=EOF)
    printf("%c",i);
    }

    Answer:

    contents of zzz.c followed by an infinite loop

    Explanation:

    The condition is checked against EOF, it should be checked against NULL.
  4. main()
    {
     int i =0;j=0;
     if(i && j++)
       	printf("%d..%d",i++,j);
    printf("%d..%d,i,j);
    }

    Answer:

    0..0

    Explanation:

    The value of i is 0. Since this information is enough to determine the truth value of the boolean expression. So the statement following the if statement is not executed. The values of i and j remain unchanged and get printed.

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