C Programming Language: Test Your Skills! Trivia Quiz

30 Questions | Total Attempts: 81

SettingsSettingsSettings
C Programming Language: Test Your Skills! Trivia Quiz - Quiz

Are you looking to test your skills when it comes to the C programming language? This is the most popular language when it comes to writing operating software due to its flexibility and easy to use. The name from this application came up as a result of it coming after the B language. See how good you are in using it by taking this quiz.


Questions and Answers
  • 1. 
    Point out the correct statements are correct about the program below? #include<stdio.h> int main() { char ch; while(x=0;x<=255;x++) printf("ASCII value of %d character %c\n", x, x); return 0; }
    • A. 

      The code generates an infinite loop

    • B. 

      The code prints all ASCII values and its characters

    • C. 

      Error: x undeclared identifier

    • D. 

      Error: while statement missing

  • 2. 
    Which of the following is the correct usage of conditional operators used in C?
    • A. 

      A>b ? c=30 : c=40;

    • B. 

      A>b ? c=30;

    • C. 

      Max = a>b ? a>c?a:c:b>c?b:c

    • D. 

      Return (a>b)?(a:b)

  • 3. 
    What will be the output of the program? #include<stdio.h> #include<math.h> int main() { float n=1.54; printf("%f, %f\n", ceil(n), floor(n)); return 0; }
    • A. 

      2.000000, 1.000000

    • B. 

      1.500000, 1.500000

    • C. 

      1.550000, 2.000000

    • D. 

      1.000000, 2.000000

  • 4. 
    What will be the output of the program? #include<stdio.h> int main() { float d=2.25; printf("%e,", d); printf("%f,", d); printf("%g,", d); printf("%lf", d); return 0; }
    • A. 

      2.2, 2.50, 2.50, 2.5

    • B. 

      2.2e, 2.25f, 2.00, 2.25

    • C. 

      2.250000e+000, 2.250000, 2.25, 2.250000

    • D. 

      Error

  • 5. 
    Point out the error in the program #include<stdio.h> int main() { int i; #if A printf("Enter any number:"); scanf("%d", &i); #elif B printf("The number is odd"); return 0; }
    • A. 

      Error: unexpected end of file because there is no matching #endif

    • B. 

      The number is odd

    • C. 

      Garbage values

    • D. 

      None of above

  • 6. 
    If a function contains two return statements successively, the compiler will generate warnings.
    • A. 

      True

    • B. 

      False

  • 7. 
    What will be the output of the program ? #include<stdio.h> int main() { float arr[] = {12.4, 2.3, 4.5, 6.7}; printf("%d\n", sizeof(arr)/sizeof(arr[0])); return 0; }
    • A. 

      5

    • B. 

      4

    • C. 

      6

    • D. 

      7

  • 8. 
    Which of the following statements correct about the below program? #include<stdio.h> int main() { union a { int i; char ch[2]; }; union a u1 = {512}; union a u2 = {0, 2}; return 0; } 1: u2 CANNOT be initialized as shown. 2: u1 can be initialized as shown. 3: To initialize char ch[] of u2 '.' operator should be used. 4: The code causes an error 'Declaration syntax error'
    • A. 

      1,2

    • B. 

      2,3

    • C. 

      1,2,3

    • D. 

      2,4

  • 9. 
    Is there any difference int the following declarations? int fun(int arr[]); int fun(int arr[2]);
    • A. 

      True

    • B. 

      False

  • 10. 
    What will be the output of the program? #include<stdio.h> int get(); int main() { const int x = get(); printf("%d", x); return 0; } int get() { return 20; }
    • A. 

      Garbage value

    • B. 

      20

    • C. 

      Error

    • D. 

      0

  • 11. 
    Does there exist any way to make the command-line arguments available to other functions without passing them as arguments to the function?
    • A. 

      True

    • B. 

      False

  • 12. 
    Point out the error in the program. #include<stdio.h> #include<stdlib.h> int fun(const union employee *e); union employee { char name[15]; int age; float salary; }; const union employee e1; int main() { strcpy(e1.name, "A"); fun(&e1); printf("%s %d %f", e1.name, e1.age, e1.salary); return 0; } int fun(const union employee *e) { strcpy((*e).name, "B"); return 0; }
    • A. 

      Error: RValue required

    • B. 

      Error: cannot convert parameter 1 from 'const char[15]' to 'char *'

    • C. 

      Error: LValue required in strcpy

    • D. 

      No error

  • 13. 
    What function should be used to free the memory allocated by calloc() ?
    • A. 

      Dealloc();

    • B. 

      Malloc(variable_name, 0)

    • C. 

      Free();

    • D. 

      Memalloc(variable_name, 0)

  • 14. 
    Point out the correct statement which correctly free the memory pointed to by 's' and 'p' in the following program? #include<stdio.h> #include<stdlib.h> int main() { struct ex { int i; float j; char *s }; struct ex *p; p = (struct ex *)malloc(sizeof(struct ex)); p->s = (char*)malloc(20); return 0; }
    • A. 

      Free(p); , free(p->s);

    • B. 

      free(p->s); , free(p);

    • C. 

      Free(p->s);

    • D. 

      Free(p);

  • 15. 
    What do the following declaration signify? void *cmp();
    • A. 

      Cmp is a pointer to an void type.

    • B. 

      Cmp is a void type pointer variable.

    • C. 

      Cmp is a function that return a void pointer.

    • D. 

      Cmp function returns nothing.

  • 16. 
    What will be the output of the program? #include<stdio.h> int main() { char huge *near *far *ptr1; char near *far *huge *ptr2; char far *huge *near *ptr3; printf("%d, %d, %d\n", sizeof(**ptr1), sizeof(ptr2), sizeof(*ptr3)); return 0; }
    • A. 

      4,4,4

    • B. 

      2,2,2

    • C. 

      2,4,8

    • D. 

      2,8,4

  • 17. 
    Point out the error in the following program. #include<stdio.h> void display(int (*ff)()); int main() { int show(); int (*f)(); f = show; display(f); return 0; } void display(int (*ff)()) { (*ff)(); } int show() { printf("c-skills"); }
    • A. 

      Error: invalid parameter in function display()

    • B. 

      Error: invalid function call f=show;

    • C. 

      No error and prints "c-skills"

    • D. 

      None

  • 18. 
    Which of the following function sets first n characters of a string to a given character?
    • A. 

      Strinit()

    • B. 

      Strnset()

    • C. 

      Strset()

    • D. 

      Strcset()

  • 19. 
    We can modify the pointers "source" as well as "target".
    • A. 

      True

    • B. 

      False

  • 20. 
    Will the program outputs "users-choice.blogspot.com"? #include<stdio.h> #include<string.h> int main() { char str1[] = "users-choice.blogspot.com"; char str2[20]; strncpy(str2, str1, 8); printf("%s", str2); return 0; }
    • A. 

      True

    • B. 

      False

  • 21. 
    Can we use a switch statement to switch on strings?
    • A. 

      True

    • B. 

      False

  • 22. 
    Is it true that too many recursive calls may result into stack overflow?
    • A. 

      True

    • B. 

      False

  • 23. 
    A macro must always be defined in capital letters.
    • A. 

      True

    • B. 

      False

  • 24. 
    In a macro call the control is passed to the macro.
    • A. 

      True

    • B. 

      False

  • 25. 
    A header file contains macros, structure declaration and function prototypes.
    • A. 

      True

    • B. 

      False

Back to Top Back to top