C Language Programming Test! Trivia Quiz

20 Questions | Total Attempts: 149

SettingsSettingsSettings
C Language Programming Test! Trivia Quiz - Quiz

What do you know about C language programming? There are so many different types of computer languages, and it can be a daunting task to know which is which. C language is a structure-oriented programming language, and it is within the middle level of programming. The Windows program is written in C language, and there are some basic rules for success with this language. Take this test and find out if you are successful in learning about C language programming.


Questions and Answers
  • 1. 
    Which of the following shows the correct hierarchy of arithmetic operations in C? 
    • A. 

      / + * –

    • B. 

      * – / +

    • C. 

      + – / *

    • D. 

      * / + –

  • 2. 
    What will happen if in a C program you assign a value to an array element whose subscript exceeds the size of the array?
    • A. 

      The element will be set to 0.

    • B. 

      The compiler would report an error.

    • C. 

      The program may crash if some important data gets overwritten.

    • D. 

      The array size would appropriately grow.

  • 3. 
    int testarray[3][2][2] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}; What value does testarray[2][1][0] in the sample code above contain?
    • A. 

      11

    • B. 

      7

    • C. 

      5

    • D. 

      9

  • 4. 
    What will be the output of the following statements? int i = 3; printf(“%d%d”,i,i++);                          
    • A. 

      34

    • B. 

      43

    • C. 

      44

    • D. 

      33

  • 5. 
    With what do you replace the? long factorial (long x) { ???? return x * factorial(x – 1); }
    • A. 

      If (x == 0) return 0;

    • B. 

      Return 1;

    • C. 

      If (x >= 2) return 2;

    • D. 

      If (x <= 1) return 1;

  • 6. 
    What would be the output of the following program? #include main() { char str[]=”S\065AB”; printf(“\n%d”, sizeof(str)); }
    • A. 

      7

    • B. 

      6

    • C. 

      5

    • D. 

      Error

  • 7. 
    What will be the output? int main() {             char *str="includehelp";             printf("%s",str+7);             return 0; }
    • A. 

      Help     

    • B. 

                  includehelp

    • C. 

      Ehelp

    • D. 

      None of these

  • 8. 
    What will be the output in the given input?     int main() { int n,i=0; while(scanf("%d",&n)==1) { printf("END\n"); } return 0; }
    • A. 

      Runtime_error and Compile time error

    • B. 

      Compile time error and Runtime_error

    • C. 

      Syntax error and Syntax error

    • D. 

      No output and END

  • 9. 
    What will be the output of following program (on 32 bit compiler)? #include int main() {     int x=65;     const unsigned char c=(int)x;         printf("%c\n",c);     return 0; }
    • A. 

      65.00

    • B. 

      65

    • C. 

      A

    • D. 

      Error

  • 10. 
    Which header file should be included to use functions like malloc() and calloc()?
    • A. 

      Memory.h

    • B. 

      Stdlib.h

    • C. 

      String.h

    • D. 

      Dos.h

  • 11. 
    What is (void*)0?
    • A. 

      Representation of NULL pointer

    • B. 

      Representation of void pointer

    • C. 

      Error

    • D. 

      None of above

  • 12. 
    How many bytes are occupied by near, far and huge pointers (DOS)?
    • A. 

      Near=2 far=4 huge=4

    • B. 

      Near=4 far=8 huge=8

    • C. 

      Near=2 far=4 huge=8

    • D. 

      Near=4 far=4 huge=8

  • 13. 
    What would be the equivalent pointer expression for referring the array element a[i][j][k][l]                                                                
    • A. 

      ((((a+i)+j)+k)+l)

    • B. 

      *(*(*(*(a+i)+j)+k)+l)

    • C. 

      (((a+i)+j)+k+l)

    • D. 

      ((a+i)+j+k+l)

  • 14. 
    The following program reports an error on compilation.        #include int main() {     float i=10, *j;     void *k;     k=&i;     j=k;     printf("%f\n", *j);     return 0; }
    • A. 

      True

    • B. 

      False

  • 15. 
    Point out the compile time error in the program given below. #include int main() {     int *x;     *x=100;     return 0; }
    • A. 

      Error: invalid assignment for x

    • B. 

      Error: suspicious pointer conversion

    • C. 

      No error

    • D. 

      None of above

  • 16. 
    How many times the below loop will run? main() {             int i;             i=0;             do             {                         --i;                         printf("%d",i);                         i++;             }             while(i>=0);
    • A. 

      1

    • B. 

      Infinite

    • C. 

      0

    • D. 

      Compilation Error  

  • 17. 
    What will be the output                                                     main() {             int i, j, *ptr, *ptr1;             i = 10;             j = 10;             ptr = &i;             ptr1 = &j;             if(ptr == ptr1)             {                         printf("True");             }             else             {                         printf("False");             } }
    • A. 

      True

    • B. 

      False

    • C. 

      Syntax Error 

    • D. 

      Run time Error

  • 18. 
    Which of the statements is correct about the program?  #include int main() { int i=10; int *j=&i; return 0; }
    • A. 

      J and i are pointers to an int

    • B. 

      I is a pointer to an int and stores address of j

    • C. 

      J is a pointer to an int and stores address of i

    • D. 

      J is a pointer to a pointer to an int and stores address of i

  • 19. 
    What will be the output                                                      main() {             float me = 1.1;             double you = 1.1;             if(me==you) printf("I love U"); else                         printf("I hate U"); }  
    • A. 

      I Love U

    • B. 

      Love You

    • C. 

      I hate U

    • D. 

      I Hate You

  • 20. 
    Which of the following function calculates the square of 'x' in C?  
    • A. 

      Sqr(x)

    • B. 

      Pow(2, x)

    • C. 

      Pow(x, 2)

    • D. 

      Power(2, x)

Back to Top Back to top