C LANGUAGE QUIZ
1 .
fseek() should be preferred over rewind() mainly because

Correct Answer : Option (C)

In rewind, there is no way to check if the operations completed successfully
  Show Answer
2 .
How many times does the loop run?
 
#include <stdio.h> 
int main() 
{ 
    int i; 
    for (i = 1; i <= 100; i++) { 
        printf("GFG\n"); 
        if (i == 5) 
            break; 
    } 
    return (0); 
} 

Correct Answer : Option (A)

5 times
  Show Answer
3 .
what will be the output?
 
#include <stdio.h> 
int main() 
{ 
    int i; 
    for (i = 1; i <= 10; i++) { 
        printf("welcome\n"); 
        continue; 
        printf("hii"); 
    } 
    return (0); 
}

Correct Answer : Option (D)

print welcome 10 times
  Show Answer
4 .
Which of the above three functions are likely to cause problems with pointers?

Correct Answer : Option (C)

Only P1 and P2
  Show Answer
5 .
What is the return type of malloc() or calloc()

Correct Answer : Option (A)

void *
  Show Answer
6 .
Which of the following is true?

Correct Answer : Option (B)

"ptr = calloc(m, n)" is equivalent to following
ptr = malloc(m * n); memset(ptr, 0, m * n);
  Show Answer
7 .
Consider the following variable declarations and definitions in C
i) int var_9 = 1;
ii) int 9_var = 2;
iii) int _ = 3;
 
Choose the correct statement w.r.t. above variables.

Correct Answer : Option (A)

Both i) and iii) are valid.
  Show Answer
8 .
What is the output of the below program?
#include <stdio.h>
int main()
{
    int i = 0;
    switch (i)
    {
        case '0': printf("Free");
                break;
        case '1': printf("Time");
                break;
        default: printf("FreeQuiz");
    }
    return 0;
}‚Äč
 

Correct Answer : Option (C)

FreeQuiz
  Show Answer
9 .
Predict the output of the below program:
#include <stdio.h>
#define EVEN 0
#define ODD 1
int main()
{
    int i = 3;
    switch (i & 1)
    {
        case EVEN: printf("Even");
                break;
        case ODD: printf("Odd");
                break;
        default: printf("Default");
    }
    return 0;
}

Correct Answer : Option (B)

Odd
  Show Answer
10 .
Consider the following C declaration

struct { 
    short s[5];
    union { 
         float y; 
         long z; 
    }u; 
} t;
 
Assume that objects of the type short, float and long occupy 2 bytes, 4 bytes and 8 bytes, respectively. The memory requirement for variable t, ignoring alignment considerations, is :

Correct Answer : Option (C)

18 bytes
  Show Answer