Welcome to C Programming Quiz, Entry Level !!

Question 1. Which bitwise operator is suitable for turning on a particular bit in a number?

&& operator

|| operator

& operator

| operator

Question 2. In the following program where is the variable a getting defined and where it is getting declared?
int main()
    extern int a;
    printf("%d\n", a);
    return 0;
int a=20;

extern int a is declaration, int a = 20 is the definition

int a = 20 is declaration, extern int a is the definition

int a = 20 is definition, a is not defined

a is declared, a is not defined

Question 3. What function should be used to free the memory allocated by calloc() ?


demalloc(variable_name, 0)


decalloc(variable_name, 0)

Question 4. Identify which of the following are declarations
1:   extern int x;
2:   float square ( float x ) { ... }
3:   double pow(double, double);



1 and 3


Question 5. What does the "auto" specifier do?

It automatically initializes a variable to 0

It indicates that a variable's memory will automatically be preserved

It automatically increments the variable when used.

It indicates that a variable's memory space is allocated upon entry into the block.

Question 6. Which of the following cannot be checked in a switch-case statement?





Question 7. What is the purpose of "rb" in fopen() function used below in the code?
FILE *fp;
fp = fopen("source.txt", "rb");

open "source.txt" in binary mode for reading

open "source.txt" in binary mode for reading and writing

Create a new file "source.txt" for reading and writing

none of the above

Question 8. Which files will get closed through the fclose() in the following program?

int main()
    FILE *fs, *ft, *fp;
    fp = fopen("A.C", "r");
    fs = fopen("B.C", "r");
    ft = fopen("C.C", "r");
    fclose(fp, fs, ft);
    return 0;

"A.C" "B.C" "C.C"

"B.C" "C.C"


error in fclose()

Question 9. Which of the following statements should be used to obtain a remainder after dividing 3.14 by 2.1 ?

rem = 3.14 % 2.1;

rem = modf(3.14, 2.1);

rem = fmod(3.14, 2.1);

Remainder cannot be obtain in floating point division.

Question 10. Which of the following operations can be performed on the file "NOTES.TXT" using the below code?
FILE *fp;
fp = fopen("NOTES.TXT", "r+");




read and write