Basics Of C Language: Trivia Quiz!

15 Questions | Total Attempts: 103

SettingsSettingsSettings
Please wait...
Basics Of C Language: Trivia Quiz!

.


Questions and Answers
  • 1. 
    Which of the following is not a valid variable name declaration in the C programming language?
    • A. 

      Int _a3

    • B. 

      Int a_3

    • C. 

      Int 3_a

    • D. 

      Int _3a

  • 2. 
    What will happen if the below program is executed?    #include    int main()    {        int main = 3;        printf("%d", main);        return 0;    }
    • A. 

      It will cause a compile-time error.

    • B. 

      It will cause a run-time error.

    • C. 

      It will run without any error and prints 3.

    • D. 

      No output and program will terminate abnormally.

  • 3. 
    What is the output of the following C code?    #include    int main()    {       signed char chr;       chr = 128;       printf("%d\n", chr);       return 0;    }
    • A. 

      128

    • B. 

      -128

    • C. 

      Depends on the compiler

    • D. 

      Compile time error as char can't be assigned an int value

  • 4. 
    What is the output of the following C code?    #include    int main()    {       int i;       if(i=0,2,3)        printf("Hello ");       else        printf("World ");            printf("%d",i);       return 0;    }
    • A. 

      World 3

    • B. 

      World 0

    • C. 

      Hello 0

    • D. 

      Hello 3

  • 5. 
    What is the output of the following C code?    #include <stdio.h>    int main()    {       int i=0,j=0;       while(i<5,j<10)       {        i++;            j++;       }     printf("%d %d",i,j);     return 0;    }
    • A. 

      5 5

    • B. 

      10 10

    • C. 

      10 5

    • D. 

      5 10

  • 6. 
    What will be the output of this C code?    #include <stdio.h>    int main()    {        float f1 = 0.1;        if (f1 == 0.1)            printf("equal\n");        else            printf("not equal\n");      return 0;    }
    • A. 

      Equal

    • B. 

      Not equal

    • C. 

      Output depends upon compiler

    • D. 

      Compile-time error

  • 7. 
    What is ‘short int’ in C programming?
    • A. 

      A basic data type

    • B. 

      Qualifier

    • C. 

      Modifier

    • D. 

      ‘short’ is qualifier, ‘int’ is basic data type.

  • 8. 
    Does this code compile without error(s)?    // no header files included    int main()    {        int k;        {            int k;            for (k = 0; k < 10; k++);   // there’s a semicolon in the end!        }     return 0;    }
    • A. 

      Yes

    • B. 

      No

    • C. 

      Depends on the compiler

    • D. 

      Depends on the C standard you are using

  • 9. 
    What is the output of this C code?    #include     int main()    {     int i;     scanf(“%d”, &i);    // inputting 071     printf(“%d”, i);     return 0;         }
    • A. 

      071

    • B. 

      71

    • C. 

      57

    • D. 

      56

  • 10. 
    What is the output of this C code?    #include<stdio.h>    int main()    {     printf(“%d”, printf(“Hello 2018! ”));     return 0; }        
    • A. 

      Compile time error

    • B. 

      Hello 2018!

    • C. 

      12

    • D. 

      Hello 2018! 12

  • 11. 
    What is the output of this C code?   #include <stdio.h>    int main()    {     if(printf("foo"))      switch(printf("bar"))       while(printf("infinite"));         return 0;         }
    • A. 

      Foobarinfiniteinfiniteinfinite………∞

    • B. 

      Foobar

    • C. 

      Foobarinfinite

    • D. 

      Compile-time error

  • 12. 
    What is the output of this C code?   #include <stdio.h>    #define square(x) x*x    int main()    {     int a = 2;     int sqr = square(a+1);     printf(“%d”,sqr);     return 0;         }
    • A. 

      3

    • B. 

      4

    • C. 

      5

    • D. 

      6

  • 13. 
    What will be the value of d in the following program? #include int main() {   int a = 10, b = 5, c = 5;   int d;   d = b + (c == a);   printf("%d", d); }
    • A. 

      Syntax Error

    • B. 

      1

    • C. 

      5

    • D. 

      10

  • 14. 
    What is the output of this C code? #include <stdio.h> int main()    {        int i = 3;        int l = i / -2;        int k = i % -2;        printf("%d %d\n", l, k);        return 0;    }
    • A. 

      Compile time error

    • B. 

      -1 1

    • C. 

      1 -1

    • D. 

      Implementation defined

  • 15. 
    What is the Output of this C code? #include <stdio.h>    int main()    {        int a = 10;        if (a == a--)            printf("TRUE 1\t");        a = 10;        if (a == --a)            printf("TRUE 2\t");    }
    • A. 

      TRUE 1

    • B. 

      TRUE 2

    • C. 

      TRUE 1 TRUE 2

    • D. 

      Compiler Dependent