Welcome to C Programming Quiz, Randomly Selected !!

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


demalloc(variable_name, 0)


decalloc(variable_name, 0)

Question 2. Which bitwise operator is suitable for turning off a particular bit in a number?

&& operator

& operator

|| operator

| operator

Question 3. How many times the while loop will get executed if a short int is 2 byte wide?
int main()
    int j=1;
    while(j <= 255)
        printf("%c %d\n", j, j);
    return 0;

infinite number of times

255 times

256 times

254 times

Question 4. 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 5. what will be the output of the following program
int fun(int **ptr);

int main()
    int i=10;
    const int *ptr = &i;
    return 0;
int fun(int **ptr)
    int j = 223;
    int *temp = &j;
    printf("Before changing ptr = %5x\n", *ptr);
    const *ptr = temp;
    printf("After changing ptr = %5x\n", *ptr);
    return 0;

address of i
     address of j


Error: cannot convert parameter 1 from 'const int **' to 'int **'

garbage value

Question 6. 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 7. The following program releases memory from a link list..which of the following is true?
struct node *nPtr, *sPtr;    /* pointers for a linked list. */ 
for (nPtr=sPtr; nPtr; nPtr=nPtr->next)

It will work correctly since the for loop covers the entire list.

It may fail since each node "nPtr" is freed before its next address can be accessed.

In the for loop, the assignment "nPtr=nPtr->next" should be changed to "nPtr=nPtr.next".

The loop will never end.

Question 8. What can be the missing statement for the code to work properly?
int main(void) {
                array x={1,2,3,4,5};
                printf("%d", x[2]);
                return 0;

#define array int[]

#define array int*

typedef array int[]

typedef array int*

Question 9. If the binary eauivalent of 5.375 in normalised form is 0100 0000 1010 1100 0000 0000 0000 0000, what will be the output of the program (on intel machine)?
int main()
    float a=5.375;
    char *p;
    int i;
    p = (char*)&a;
    for(i=0; i<=3; i++)
        printf("%x\n", (unsigned char)p[i]);
    return 0;

40 AC 00 00

04 CA 00 00

00 00 AC 40

00 00 CA 04

Question 10. What would be the equivalent pointer expression for referring the array element a[i][j][k][l]